Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-10-15 03:56:12
Exec Total Coverage
Lines: 1669 4298 38.8%
Functions: 130 334 38.9%
Branches: 924 2934 31.5%

Line Branch Exec Source
1 #include "zc/zc_sys.h"
2
3 #include "allegro/gfx.h"
4 #include "allegro5/joystick.h"
5 #include "base/qrs.h"
6 #include "base/dmap.h"
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <cstring>
10 #include <math.h>
11 #include <map>
12 #include <filesystem>
13 #include <ctype.h>
14 #include <sstream>
15 #include "base/zc_alleg.h"
16 #include "gamedata.h"
17 #include "zc/zc_init.h"
18 #include "init.h"
19 #include "zc/replay.h"
20 #include "zc/cheats.h"
21 #include "zc/render.h"
22 #include "base/zc_math.h"
23 #include "base/zapp.h"
24 #include "dialog/cheatkeys.h"
25 #include "metadata/metadata.h"
26 #include "zc/zelda.h"
27 #include "zc/saves.h"
28 #include "tiles.h"
29 #include "base/colors.h"
30 #include "pal.h"
31 #include "base/zsys.h"
32 #include "qst.h"
33 #include "zc/zc_sys.h"
34 #include "play_midi.h"
35 #include "jwin_a5.h"
36 #include "base/jwinfsel.h"
37 #include "base/gui.h"
38 #include "midi.h"
39 #include "subscr.h"
40 #include "zc/maps.h"
41 #include "sprite.h"
42 #include "zc/guys.h"
43 #include "zc/hero.h"
44 #include "zc/title.h"
45 #include "particles.h"
46 #include "zcmusic.h"
47 #include "zconsole.h"
48 #include "zc/ffscript.h"
49 #include "dialog/info.h"
50 #include "dialog/alert.h"
51 #include "zc/combos.h"
52 #include "zc/jit.h"
53 #include "zc/zc_subscr.h"
54 #include <fmt/format.h>
55 #include "zinfo.h"
56 #include "base/misctypes.h"
57
58 #ifdef __EMSCRIPTEN__
59 #include "base/emscripten_utils.h"
60 #endif
61
62 using namespace std::chrono_literals;
63
64 extern FFScript FFCore;
65 extern bool Playing;
66 int32_t sfx_voice[WAV_COUNT];
67 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
68 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
69
70 static ALLEGRO_JOYSTICK* gamepad_dlg_cur_joystick;
71 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c);
72
73 extern byte monochrome_console;
74
75 extern HeroClass Hero;
76 extern zcmodule moduledata;
77 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
78 extern particle_list particles;
79 extern int32_t loadlast;
80 extern char *sfx_string[WAV_COUNT];
81 byte use_dwm_flush;
82 byte use_save_indicator;
83 int32_t paused_midi_pos = 0;
84 byte midi_suspended = 0;
85 byte zc_192b163_warp_compatibility;
86 char modulepath[2048];
87 bool epilepsyFlashReduction;
88 signed char pause_in_background_menu_init = 0;
89 byte pause_in_background = 0;
90 bool is_sys_pal = false;
91 static bool load_control_called_this_frame;
92 extern PALETTE* hw_palette;
93 extern bool update_hw_pal;
94 extern const char* dmaplist(int32_t index, int32_t* list_size);
95 int32_t getnumber(const char *prompt,int32_t initialval);
96
97 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
98 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
99
100 static const char *qst_module_name = "current_module";
101 #ifdef ALLEGRO_LINUX
102 static const char *samplepath = "samplesoundset/patches.dat";
103 #endif
104 char qst_files_path[2048];
105
106 #ifdef _MSC_VER
107 #define getcwd _getcwd
108 #endif
109
110 bool rF11();
111 bool rI();
112 bool rQ();
113 bool zc_key_pressed();
114
115 #ifdef _WIN32
116
117 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
118 extern "C"
119 {
120 typedef HRESULT(WINAPI *t_DwmFlush)();
121 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
122 }
123
124 void do_DwmFlush()
125 {
126 static HMODULE shell = LoadLibrary("dwmapi.dll");
127
128 if(!shell)
129 return;
130
131 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
132 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
133
134 BOOL enabled;
135 isEnabled(&enabled);
136
137 if(isEnabled)
138 flush();
139 }
140
141 #endif // _WIN32
142
143 83751 bool flash_reduction_enabled(bool check_qr)
144 {
145
4/4
✓ Branch 0 taken 81530 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 81074 times.
✓ Branch 3 taken 83295 times.
83751 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
146 }
147
148 // Dialogue largening
149 void large_dialog(DIALOG *d)
150 {
151 large_dialog(d, 1.5);
152 }
153
154 void large_dialog(DIALOG *d, float RESIZE_AMT)
155 {
156 if(!d[0].d1)
157 {
158 d[0].d1 = 1;
159 int32_t oldwidth = d[0].w;
160 int32_t oldheight = d[0].h;
161 int32_t oldx = d[0].x;
162 int32_t oldy = d[0].y;
163 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
164 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
165 d[0].w = int32_t(d[0].w*RESIZE_AMT);
166 d[0].h = int32_t(d[0].h*RESIZE_AMT);
167
168 for(int32_t i=1; d[i].proc !=NULL; i++)
169 {
170 // Place elements horizontally
171 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
172 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
173
174 if(d[i].proc != d_stringloader)
175 {
176 if(d[i].proc==d_bitmap_proc)
177 {
178 d[i].w *= 2;
179 }
180 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
181 }
182
183 // Place elements vertically
184 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
185 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
186
187 // Vertically resize elements
188 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
189 {
190 d[i].h = int32_t((double)d[i].h*1.5);
191 }
192 else if(d[i].proc == jwin_droplist_proc || d[i].proc == d_joylist_proc)
193 {
194 d[i].y += int32_t((double)d[i].h*0.25);
195 d[i].h = int32_t((double)d[i].h*1.25);
196 }
197 else if(d[i].proc==d_bitmap_proc)
198 {
199 d[i].h *= 2;
200 }
201 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
202
203 // Fix frames
204 if(d[i].proc == jwin_frame_proc)
205 {
206 d[i].x++;
207 d[i].y++;
208 d[i].w-=4;
209 d[i].h-=4;
210 }
211 }
212 }
213
214 for(int32_t i=1; d[i].proc!=NULL; i++)
215 {
216 if(d[i].proc==jwin_slider_proc)
217 continue;
218
219 // Bigger font
220 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc && d[i].proc != d_joylist_proc);
221
222 if(!d[i].dp2 && bigfontproc)
223 {
224 d[i].dp2 = get_zc_font(font_lfont_l);
225 }
226 else if(!bigfontproc)
227 {
228 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
229 }
230
231 // Make checkboxes work
232 if(d[i].proc == jwin_check_proc)
233 d[i].proc = jwin_checkfont_proc;
234 else if(d[i].proc == jwin_radio_proc)
235 d[i].proc = jwin_radiofont_proc;
236 }
237
238 jwin_center_dialog(d);
239 }
240
241
242 /**********************************/
243 /******** System functions ********/
244 /**********************************/
245
246 static char cfg_sect[] = "zeldadx"; //We need to rename this.
247 static char ctrl_sect[] = "Controls";
248 static char sfx_sect[] = "Volume";
249
250 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
251 {
252 return D_O_K;
253 }
254
255 bool is_reserved_key(int c)
256 {
257 switch(c)
258 {
259 case KEY_ESC:
260 return true;
261 }
262 return false;
263 }
264 bool is_reserved_keycombo(int c, int modflag)
265 {
266 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
267 return true;
268 return false;
269 }
270 bool checkcheat(Cheat cheat)
271 {
272 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
273 return true; //Main key pressed
274 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
275 return true; //Alt key pressed
276 return false;
277 }
278 114 void load_default_cheatkeys()
279 {
280 114 memset(cheatkeys, 0, sizeof(cheatkeys));
281 114 cheatkeys[Cheat::Life][0] = KEY_H;
282 114 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
283 114 cheatkeys[Cheat::Magic][0] = KEY_M;
284 114 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
285 114 cheatkeys[Cheat::Rupies][0] = KEY_R;
286 114 cheatkeys[Cheat::Bombs][0] = KEY_B;
287 114 cheatkeys[Cheat::Arrows][0] = KEY_A;
288 114 cheatkeys[Cheat::Clock][0] = KEY_I;
289 114 cheatkeys[Cheat::Walls][0] = KEY_F11;
290 114 cheatkeys[Cheat::Fast][0] = KEY_Q;
291 114 cheatkeys[Cheat::Light][0] = KEY_L;
292 114 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
293 114 cheatkeys[Cheat::Kill][0] = KEY_K;
294 114 cheatkeys[Cheat::GoTo][0] = KEY_G;
295 114 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
296 114 cheatkeys[Cheat::ShowL0][0] = KEY_0;
297 114 cheatkeys[Cheat::ShowL1][0] = KEY_1;
298 114 cheatkeys[Cheat::ShowL2][0] = KEY_2;
299 114 cheatkeys[Cheat::ShowL3][0] = KEY_3;
300 114 cheatkeys[Cheat::ShowL4][0] = KEY_4;
301 114 cheatkeys[Cheat::ShowL5][0] = KEY_5;
302 114 cheatkeys[Cheat::ShowL6][0] = KEY_6;
303 114 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
304 114 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
305 114 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
306 114 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
307 114 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
308 114 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
309 114 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
310 114 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
311 114 }
312 114 void load_game_configs()
313 {
314 114 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
315 114 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
316 114 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
317 114 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
318 114 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
319 114 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
320 114 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
321 114 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
322 114 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
323 114 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
324 114 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
325 114 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
326 114 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
327 114 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
328 114 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
329
330 //cheat modifier keya
331 114 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
332 114 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
333 114 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
334 114 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
335
336 //cheat keys
337 114 load_default_cheatkeys();
338 char buf[256];
339
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 3990 times.
4104 for(size_t q = 1; q < Cheat::Last; ++q)
340 {
341
1/2
✓ Branch 0 taken 3990 times.
✗ Branch 1 not taken.
3990 if(!bindable_cheat((Cheat)q)) continue;
342 3990 std::string cheatname = cheat_to_string((Cheat)q);
343
1/2
✓ Branch 0 taken 3990 times.
✗ Branch 1 not taken.
3990 util::lowerstr(cheatname);
344 3990 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
345
1/2
✓ Branch 0 taken 3990 times.
✗ Branch 1 not taken.
3990 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
346 3990 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
347
1/2
✓ Branch 0 taken 3990 times.
✗ Branch 1 not taken.
3990 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
348 3990 }
349
350
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
351 joystick_index = 0;
352
353 114 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
354 114 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
355 114 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
356 114 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
357 114 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
358 114 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
359 114 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
360 114 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
361 114 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
362 114 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
363
364 114 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
365 114 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
366 114 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
367 114 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
368
369 114 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
370 114 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
371 114 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
372 114 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
373 114 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
374 114 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
375 114 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
376 114 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
377 114 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
378 114 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
379 114 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
380
381 114 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
382 114 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
383 114 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
384 114 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
385
386 114 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
387
388 114 digi_volume = zc_get_config(sfx_sect,"digi",248);
389 114 midi_volume = zc_get_config(sfx_sect,"midi",255);
390 114 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
391 114 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
392 114 pan_style = zc_get_config(sfx_sect,"pan",1);
393 // 1 <= zcmusic_bufsz <= 128
394 114 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
395 114 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
396 114 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
397 114 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
398 114 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
399 114 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
400 114 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
401 #ifdef __EMSCRIPTEN__
402 if (em_is_mobile()) NameEntryMode = 2;
403 #endif
404 114 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
405 114 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
406 114 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
407 114 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
408 114 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
409
410 //default - scale x2, 640 x 480
411 114 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
412 114 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
413 114 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
414 114 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
415 114 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
416 114 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
417 114 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
418
419 114 loadlast = zc_get_config(cfg_sect,"load_last",0);
420
421 114 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
422
423 114 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
424
425 114 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
426 114 info_opacity = zc_get_config("zc","debug_info_opacity",255);
427 #ifdef _WIN32
428 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
429 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
430 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
431 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
432
433 // This one's for Aero
434 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
435
436 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
437 #else //UNIX
438 114 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
439 114 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
440 114 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
441 #endif
442 114 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
443 114 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
444
445 114 strcpy(qstdir,zc_get_config(cfg_sect,"quest_dir","quests"));
446 114 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
447 114 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
448 114 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
449 114 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
450 114 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
451 114 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
452 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
453 114 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
454 114 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
455 114 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
456 114 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
457 114 }
458
459 void save_control_configs(bool kb)
460 {
461 if(kb)
462 {
463 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
464 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
465 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
466 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
467
468 if (!replay_is_replaying())
469 {
470 zc_set_config(ctrl_sect,"key_a",Akey);
471 zc_set_config(ctrl_sect,"key_b",Bkey);
472 zc_set_config(ctrl_sect,"key_s",Skey);
473 zc_set_config(ctrl_sect,"key_l",Lkey);
474 zc_set_config(ctrl_sect,"key_r",Rkey);
475 zc_set_config(ctrl_sect,"key_p",Pkey);
476 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
477 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
478 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
479 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
480 zc_set_config(ctrl_sect,"key_up", DUkey);
481 zc_set_config(ctrl_sect,"key_down", DDkey);
482 zc_set_config(ctrl_sect,"key_left", DLkey);
483 zc_set_config(ctrl_sect,"key_right",DRkey);
484 }
485 }
486 else
487 {
488 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
489 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
490 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
491 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
492 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
493 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
494 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
495 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
496 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
497 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
498 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
499 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
500 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
501 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
502
503 zc_set_config(ctrl_sect,"btn_a",Abtn);
504 zc_set_config(ctrl_sect,"btn_b",Bbtn);
505 zc_set_config(ctrl_sect,"btn_s",Sbtn);
506 zc_set_config(ctrl_sect,"btn_m",Mbtn);
507 zc_set_config(ctrl_sect,"btn_l",Lbtn);
508 zc_set_config(ctrl_sect,"btn_r",Rbtn);
509 zc_set_config(ctrl_sect,"btn_p",Pbtn);
510 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
511 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
512 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
513 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
514
515 zc_set_config(ctrl_sect,"btn_up",DUbtn);
516 zc_set_config(ctrl_sect,"btn_down",DDbtn);
517 zc_set_config(ctrl_sect,"btn_left",DLbtn);
518 zc_set_config(ctrl_sect,"btn_right",DRbtn);
519 }
520 }
521
522 void save_cheatkeys()
523 {
524 char buf[256];
525 for(size_t q = 1; q < Cheat::Last; ++q)
526 {
527 if(!bindable_cheat((Cheat)q)) continue;
528 std::string cheatname = cheat_to_string((Cheat)q);
529 util::lowerstr(cheatname);
530 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
531 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
532 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
533 if(cheatkeys[q][1])
534 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
535 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
536 }
537 }
538
539 void save_game_configs()
540 {
541 packfile_password("");
542
543 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
544
545 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
546 {
547 int o_window_x, o_window_y;
548 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
549 zc_set_config(cfg_sect,"window_x",o_window_x);
550 zc_set_config(cfg_sect,"window_y",o_window_y);
551 }
552
553 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
554 {
555 double monitor_scale = zc_get_monitor_scale();
556 window_width = al_get_display_width(all_get_display()) / monitor_scale;
557 window_height = al_get_display_height(all_get_display()) / monitor_scale;
558 zc_set_config(cfg_sect,"window_width",window_width);
559 zc_set_config(cfg_sect,"window_height",window_height);
560 }
561
562 zc_set_config(cfg_sect,"load_last",loadlast);
563 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
564
565 flush_config_file();
566 #ifdef __EMSCRIPTEN__
567 em_sync_fs();
568 #endif
569 }
570
571 //----------------------------------------------------------------
572
573 // Timers
574
575 28287 void fps_callback()
576 {
577 28287 lastfps=framecnt;
578 28287 dword tempsecs = fps_secs;
579 28287 ++tempsecs;
580 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
581 28287 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
582 28287 ++fps_secs;
583 28287 framecnt=0;
584 28287 }
585
586 END_OF_FUNCTION(fps_callback)
587
588 114 int32_t Z_init_timers()
589 {
590 static bool didit = false;
591 const static char *err_str = "Couldn't allocate timer";
592 114 err_str = err_str; //Unused variable warning
593
594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(didit)
595 return 1;
596
597 114 didit = true;
598
599 LOCK_VARIABLE(lastfps);
600 LOCK_VARIABLE(framecnt);
601 LOCK_FUNCTION(fps_callback);
602
603
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
604 return 0;
605
606 114 return 1;
607 114 }
608
609 void Z_remove_timers()
610 {
611 remove_int(fps_callback);
612 }
613
614 //----------------------------------------------------------------
615
616 void go()
617 {
618 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
619 }
620
621 void comeback()
622 {
623 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
624 }
625
626 void dump_pal(BITMAP *dest)
627 {
628 for(int32_t i=0; i<256; i++)
629 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
630 }
631
632 //----------------------------------------------------------------
633
634 int game_mouse_index = ZCM_BLANK;
635 static bool system_mouse = false;
636 28 bool sys_mouse()
637 {
638 28 system_mouse = true;
639 28 return MouseSprite::set(ZCM_NORMAL);
640 }
641 553 bool game_mouse()
642 {
643 553 system_mouse = false;
644 553 return MouseSprite::set(game_mouse_index);
645 }
646 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
647 {
648 if(!bmp)
649 return;
650 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
651 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
652 if(bmp->w == scaledw && bmp->h == scaledh)
653 user_scale = false;
654 if(user_scale || sys_recolor)
655 {
656 if(!user_scale) scale = 1;
657 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
658 if(user_scale)
659 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
660 else
661 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
662 if(sys_recolor)
663 recolor_mouse(tmpbmp);
664 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
665 destroy_bitmap(tmpbmp);
666 }
667 else
668 {
669 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
670 }
671 }
672
673 //Handles converting the mouse sprite from the .dat file
674 void recolor_mouse(BITMAP* bmp)
675 {
676 for(int32_t x = 0; x < bmp->w; ++x)
677 {
678 for(int32_t y = 0; y < bmp->h; ++y)
679 {
680 int32_t color = getpixel(bmp, x, y);
681 switch(color)
682 {
683 case dvc(1):
684 color = jwin_pal[jcCURSORMISC];
685 break;
686 case dvc(2):
687 color = jwin_pal[jcCURSOROUTLINE];
688 break;
689 case dvc(3):
690 color = jwin_pal[jcCURSORLIGHT];
691 break;
692 case dvc(5):
693 color = jwin_pal[jcCURSORDARK];
694 break;
695 default:
696 continue;
697 }
698 putpixel(bmp, x, y, color);
699 }
700 }
701 }
702 void load_mouse()
703 {
704 PALETTE pal;
705 BITMAP* cursor_bitmap = load_bitmap("assets/cursor.bmp", pal);
706 if (!cursor_bitmap)
707 Z_error_fatal("Missing required file %s\n", "assets/cursor.bmp");
708
709 enter_sys_pal();
710 MouseSprite::set(-1);
711 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
712 int32_t sz = 16*scale;
713 for(int32_t j = 0; j < 1; ++j)
714 {
715 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
716 if(zcmouse[j])
717 destroy_bitmap(zcmouse[j]);
718 zcmouse[j] = create_bitmap_ex(8,sz,sz);
719 clear_bitmap(zcmouse[j]);
720 clear_bitmap(tmpbmp);
721 blit(cursor_bitmap,tmpbmp,1,j*17+1,0,0,16,16);
722 recolor_mouse(tmpbmp);
723 if(sz!=16)
724 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
725 else
726 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
727 destroy_bitmap(tmpbmp);
728 }
729 if(!hw_palette) hw_palette = &RAMpal;
730 zc_set_palette(*hw_palette);
731
732 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
733 clear_bitmap(blankmouse);
734
735 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
736 MouseSprite::assign(ZCM_BLANK, blankmouse);
737 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
738
739 //Reload the mouse
740 if(system_mouse)
741 sys_mouse();
742 else game_mouse();
743
744 destroy_bitmap(blankmouse);
745 destroy_bitmap(cursor_bitmap);
746 exit_sys_pal();
747 }
748
749 // sets the video mode and initializes the palette and mouse sprite
750 114 bool game_vid_mode(int32_t mode,int32_t wait)
751 {
752
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if (is_headless())
753 114 return true;
754
755 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
756 {
757 return false;
758 }
759
760 scrx = (resx-320)>>1;
761 scry = (resy-240)>>1;
762 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
763 zcmouse[q] = NULL;
764 load_mouse();
765
766 for(int32_t i=240; i<256; i++)
767 RAMpal[i]=pal_gui[i];
768
769 zc_set_palette(RAMpal);
770 clear_to_color(screen,BLACK);
771
772 rest(wait);
773 return true;
774 114 }
775
776 8 void null_quest()
777 {
778 char qstdat_string[2048];
779 8 strcpy(qstdat_string, "modules/classic/default.qst");
780
781 #ifdef __EMSCRIPTEN__
782 // The quest template data file is not included because it's really big and isn't really needed
783 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
784 // which is much smaller.
785 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
786 #endif
787
788 8 byte skip_flags[4] = { 0 };
789
790 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
791 8 }
792
793 8 void init_NES_mode()
794 {
795 8 null_quest();
796 8 }
797
798 //----------------------------------------------------------------
799
800 qword trianglelines[16]=
801 {
802 0x0000000000000000ULL,
803 0xFD00000000000000ULL,
804 0xFDFD000000000000ULL,
805 0xFDFDFD0000000000ULL,
806 0xFDFDFDFD00000000ULL,
807 0xFDFDFDFDFD000000ULL,
808 0xFDFDFDFDFDFD0000ULL,
809 0xFDFDFDFDFDFDFD00ULL,
810 0xFDFDFDFDFDFDFDFDULL,
811 0x00FDFDFDFDFDFDFDULL,
812 0x0000FDFDFDFDFDFDULL,
813 0x000000FDFDFDFDFDULL,
814 0x00000000FDFDFDFDULL,
815 0x0000000000FDFDFDULL,
816 0x000000000000FDFDULL,
817 0x00000000000000FDULL,
818 };
819
820 word screen_triangles[28][32];
821 /*
822 qword triangles[4][16]= //[direction][value]
823 {
824 {
825 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
826 },
827 {
828 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
829 },
830 {
831 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
832 },
833 {
834 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
835 }
836 };
837 */
838
839
840 /*
841 byte triangles[4][16][8]= //[direction][value][line]
842 {
843 {
844 {
845 0, 0, 0, 0, 0, 0, 0, 0
846 },
847 {
848 1, 0, 0, 0, 0, 0, 0, 0
849 },
850 {
851 2, 1, 0, 0, 0, 0, 0, 0
852 },
853 {
854 3, 2, 1, 0, 0, 0, 0, 0
855 },
856 {
857 4, 3, 2, 1, 0, 0, 0, 0
858 },
859 {
860 5, 4, 3, 2, 1, 0, 0, 0
861 },
862 {
863 6, 5, 4, 3, 2, 1, 0, 0
864 },
865 {
866 7, 6, 5, 4, 3, 2, 1, 0
867 },
868 {
869 8, 7, 6, 5, 4, 3, 2, 1
870 },
871 {
872 8, 8, 7, 6, 5, 4, 3, 2
873 },
874 {
875 8, 8, 8, 7, 6, 5, 4, 3
876 },
877 {
878 8, 8, 8, 8, 7, 6, 5, 4
879 },
880 {
881 8, 8, 8, 8, 8, 7, 6, 5
882 },
883 {
884 8, 8, 8, 8, 8, 8, 7, 6
885 },
886 {
887 8, 8, 8, 8, 8, 8, 8, 7
888 },
889 {
890 8, 8, 8, 8, 8, 8, 8, 8
891 }
892 },
893 {
894 {
895 0, 0, 0, 0, 0, 0, 0, 0
896 },
897 {
898 15, 0, 0, 0, 0, 0, 0, 0
899 },
900 {
901 14, 15, 0, 0, 0, 0, 0, 0
902 },
903 {
904 13, 14, 15, 0, 0, 0, 0, 0
905 },
906 {
907 12, 13, 14, 15, 0, 0, 0, 0
908 },
909 {
910 11, 12, 13, 14, 15, 0, 0, 0
911 },
912 {
913 10, 11, 12, 13, 14, 15, 0, 0
914 },
915 {
916 9, 10, 11, 12, 13, 14, 15, 0
917 },
918 {
919 8, 9, 10, 11, 12, 13, 14, 15
920 },
921 {
922 8, 8, 9, 10, 11, 12, 13, 14
923 },
924 {
925 8, 8, 8, 9, 10, 11, 12, 13
926 },
927 {
928 8, 8, 8, 8, 9, 10, 11, 12
929 },
930 {
931 8, 8, 8, 8, 8, 9, 10, 11
932 },
933 {
934 8, 8, 8, 8, 8, 8, 9, 10
935 },
936 {
937 8, 8, 8, 8, 8, 8, 8, 9
938 },
939 {
940 8, 8, 8, 8, 8, 8, 8, 8
941 }
942 },
943 {
944 {
945 0, 0, 0, 0, 0, 0, 0, 0
946 },
947 {
948 0, 0, 0, 0, 0, 0, 0, 1
949 },
950 {
951 0, 0, 0, 0, 0, 0, 1, 2
952 },
953 {
954 0, 0, 0, 0, 0, 1, 2, 3
955 },
956 {
957 0, 0, 0, 0, 1, 2, 3, 4
958 },
959 {
960 0, 0, 0, 1, 2, 3, 4, 5
961 },
962 {
963 0, 0, 1, 2, 3, 4, 5, 6
964 },
965 {
966 0, 1, 2, 3, 4, 5, 6, 7
967 },
968 {
969 1, 2, 3, 4, 5, 6, 7, 8
970 },
971 {
972 2, 3, 4, 5, 6, 7, 8, 8
973 },
974 {
975 3, 4, 5, 6, 7, 8, 8, 8
976 },
977 {
978 4, 5, 6, 7, 8, 8, 8, 8
979 },
980 {
981 5, 6, 7, 8, 8, 8, 8, 8
982 },
983 {
984 6, 7, 8, 8, 8, 8, 8, 8
985 },
986 {
987 7, 8, 8, 8, 8, 8, 8, 8
988 },
989 {
990 8, 8, 8, 8, 8, 8, 8, 8
991 }
992 },
993 {
994 {
995 0, 0, 0, 0, 0, 0, 0, 0
996 },
997 {
998 0, 0, 0, 0, 0, 0, 0, 15
999 },
1000 {
1001 0, 0, 0, 0, 0, 0, 15, 14
1002 },
1003 {
1004 0, 0, 0, 0, 0, 15, 14, 13
1005 },
1006 {
1007 0, 0, 0, 0, 15, 14, 13, 12
1008 },
1009 {
1010 0, 0, 0, 15, 14, 13, 12, 11
1011 },
1012 {
1013 0, 0, 15, 14, 13, 12, 11, 10
1014 },
1015 {
1016 0, 15, 14, 13, 12, 11, 10, 9
1017 },
1018 {
1019 15, 14, 13, 12, 11, 10, 9, 8
1020 },
1021 {
1022 14, 13, 12, 11, 10, 9, 8, 8
1023 },
1024 {
1025 13, 12, 11, 10, 9, 8, 8, 8
1026 },
1027 {
1028 12, 11, 10, 9, 8, 8, 8, 8
1029 },
1030 {
1031 11, 10, 9, 8, 8, 8, 8, 8
1032 },
1033 {
1034 10, 9, 8, 8, 8, 8, 8, 8
1035 },
1036 {
1037 9, 8, 8, 8, 8, 8, 8, 8
1038 },
1039 {
1040 8, 8, 8, 8, 8, 8, 8, 8
1041 }
1042 }
1043 };
1044 */
1045
1046
1047
1048 /*
1049 for (int32_t blockrow=0; blockrow<30; ++i)
1050 {
1051 for (int32_t linerow=0; linerow<8; ++i)
1052 {
1053 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1054 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1055 {
1056 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1057 ++triangleline;
1058 }
1059 }
1060 }
1061 */
1062
1063 // the ULL suffixes are to prevent this warning:
1064 // warning: integer constant is too large for "int32_t" type
1065
1066 qword triangles[4][16][8]= //[direction][value][line]
1067 {
1068 {
1069 {
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL,
1074 0x0000000000000000ULL,
1075 0x0000000000000000ULL,
1076 0x0000000000000000ULL,
1077 0x0000000000000000ULL
1078 },
1079 {
1080 0xFD00000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL,
1084 0x0000000000000000ULL,
1085 0x0000000000000000ULL,
1086 0x0000000000000000ULL,
1087 0x0000000000000000ULL
1088 },
1089 {
1090 0xFDFD000000000000ULL,
1091 0xFD00000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL,
1095 0x0000000000000000ULL,
1096 0x0000000000000000ULL,
1097 0x0000000000000000ULL
1098 },
1099 {
1100 0xFDFDFD0000000000ULL,
1101 0xFDFD000000000000ULL,
1102 0xFD00000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL,
1106 0x0000000000000000ULL,
1107 0x0000000000000000ULL
1108 },
1109 {
1110 0xFDFDFDFD00000000ULL,
1111 0xFDFDFD0000000000ULL,
1112 0xFDFD000000000000ULL,
1113 0xFD00000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL,
1116 0x0000000000000000ULL,
1117 0x0000000000000000ULL
1118 },
1119 {
1120 0xFDFDFDFDFD000000ULL,
1121 0xFDFDFDFD00000000ULL,
1122 0xFDFDFD0000000000ULL,
1123 0xFDFD000000000000ULL,
1124 0xFD00000000000000ULL,
1125 0x0000000000000000ULL,
1126 0x0000000000000000ULL,
1127 0x0000000000000000ULL
1128 },
1129 {
1130 0xFDFDFDFDFDFD0000ULL,
1131 0xFDFDFDFDFD000000ULL,
1132 0xFDFDFDFD00000000ULL,
1133 0xFDFDFD0000000000ULL,
1134 0xFDFD000000000000ULL,
1135 0xFD00000000000000ULL,
1136 0x0000000000000000ULL,
1137 0x0000000000000000ULL
1138 },
1139 {
1140 0xFDFDFDFDFDFDFD00ULL,
1141 0xFDFDFDFDFDFD0000ULL,
1142 0xFDFDFDFDFD000000ULL,
1143 0xFDFDFDFD00000000ULL,
1144 0xFDFDFD0000000000ULL,
1145 0xFDFD000000000000ULL,
1146 0xFD00000000000000ULL,
1147 0x0000000000000000ULL
1148 },
1149 {
1150 0xFDFDFDFDFDFDFDFDULL,
1151 0xFDFDFDFDFDFDFD00ULL,
1152 0xFDFDFDFDFDFD0000ULL,
1153 0xFDFDFDFDFD000000ULL,
1154 0xFDFDFDFD00000000ULL,
1155 0xFDFDFD0000000000ULL,
1156 0xFDFD000000000000ULL,
1157 0xFD00000000000000ULL
1158 },
1159 {
1160 0xFDFDFDFDFDFDFDFDULL,
1161 0xFDFDFDFDFDFDFDFDULL,
1162 0xFDFDFDFDFDFDFD00ULL,
1163 0xFDFDFDFDFDFD0000ULL,
1164 0xFDFDFDFDFD000000ULL,
1165 0xFDFDFDFD00000000ULL,
1166 0xFDFDFD0000000000ULL,
1167 0xFDFD000000000000ULL
1168 },
1169 {
1170 0xFDFDFDFDFDFDFDFDULL,
1171 0xFDFDFDFDFDFDFDFDULL,
1172 0xFDFDFDFDFDFDFDFDULL,
1173 0xFDFDFDFDFDFDFD00ULL,
1174 0xFDFDFDFDFDFD0000ULL,
1175 0xFDFDFDFDFD000000ULL,
1176 0xFDFDFDFD00000000ULL,
1177 0xFDFDFD0000000000ULL
1178 },
1179 {
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFDFDULL,
1182 0xFDFDFDFDFDFDFDFDULL,
1183 0xFDFDFDFDFDFDFDFDULL,
1184 0xFDFDFDFDFDFDFD00ULL,
1185 0xFDFDFDFDFDFD0000ULL,
1186 0xFDFDFDFDFD000000ULL,
1187 0xFDFDFDFD00000000ULL
1188 },
1189 {
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFDFDULL,
1193 0xFDFDFDFDFDFDFDFDULL,
1194 0xFDFDFDFDFDFDFDFDULL,
1195 0xFDFDFDFDFDFDFD00ULL,
1196 0xFDFDFDFDFDFD0000ULL,
1197 0xFDFDFDFDFD000000ULL
1198 },
1199 {
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFDFDULL,
1204 0xFDFDFDFDFDFDFDFDULL,
1205 0xFDFDFDFDFDFDFDFDULL,
1206 0xFDFDFDFDFDFDFD00ULL,
1207 0xFDFDFDFDFDFD0000ULL
1208 },
1209 {
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFDFDULL,
1215 0xFDFDFDFDFDFDFDFDULL,
1216 0xFDFDFDFDFDFDFDFDULL,
1217 0xFDFDFDFDFDFDFD00ULL
1218 },
1219 {
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL,
1225 0xFDFDFDFDFDFDFDFDULL,
1226 0xFDFDFDFDFDFDFDFDULL,
1227 0xFDFDFDFDFDFDFDFDULL
1228 }
1229 },
1230 {
1231 {
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL,
1236 0x0000000000000000ULL,
1237 0x0000000000000000ULL,
1238 0x0000000000000000ULL,
1239 0x0000000000000000ULL
1240 },
1241 {
1242 0x00000000000000FDULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL,
1246 0x0000000000000000ULL,
1247 0x0000000000000000ULL,
1248 0x0000000000000000ULL,
1249 0x0000000000000000ULL
1250 },
1251 {
1252 0x000000000000FDFDULL,
1253 0x00000000000000FDULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL,
1257 0x0000000000000000ULL,
1258 0x0000000000000000ULL,
1259 0x0000000000000000ULL
1260 },
1261 {
1262 0x0000000000FDFDFDULL,
1263 0x000000000000FDFDULL,
1264 0x00000000000000FDULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL,
1268 0x0000000000000000ULL,
1269 0x0000000000000000ULL
1270 },
1271 {
1272 0x00000000FDFDFDFDULL,
1273 0x0000000000FDFDFDULL,
1274 0x000000000000FDFDULL,
1275 0x00000000000000FDULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL,
1278 0x0000000000000000ULL,
1279 0x0000000000000000ULL
1280 },
1281 {
1282 0x000000FDFDFDFDFDULL,
1283 0x00000000FDFDFDFDULL,
1284 0x0000000000FDFDFDULL,
1285 0x000000000000FDFDULL,
1286 0x00000000000000FDULL,
1287 0x0000000000000000ULL,
1288 0x0000000000000000ULL,
1289 0x0000000000000000ULL
1290 },
1291 {
1292 0x0000FDFDFDFDFDFDULL,
1293 0x000000FDFDFDFDFDULL,
1294 0x00000000FDFDFDFDULL,
1295 0x0000000000FDFDFDULL,
1296 0x000000000000FDFDULL,
1297 0x00000000000000FDULL,
1298 0x0000000000000000ULL,
1299 0x0000000000000000ULL
1300 },
1301 {
1302 0x00FDFDFDFDFDFDFDULL,
1303 0x0000FDFDFDFDFDFDULL,
1304 0x000000FDFDFDFDFDULL,
1305 0x00000000FDFDFDFDULL,
1306 0x0000000000FDFDFDULL,
1307 0x000000000000FDFDULL,
1308 0x00000000000000FDULL,
1309 0x0000000000000000ULL
1310 },
1311 {
1312 0xFDFDFDFDFDFDFDFDULL,
1313 0x00FDFDFDFDFDFDFDULL,
1314 0x0000FDFDFDFDFDFDULL,
1315 0x000000FDFDFDFDFDULL,
1316 0x00000000FDFDFDFDULL,
1317 0x0000000000FDFDFDULL,
1318 0x000000000000FDFDULL,
1319 0x00000000000000FDULL
1320 },
1321 {
1322 0xFDFDFDFDFDFDFDFDULL,
1323 0xFDFDFDFDFDFDFDFDULL,
1324 0x00FDFDFDFDFDFDFDULL,
1325 0x0000FDFDFDFDFDFDULL,
1326 0x000000FDFDFDFDFDULL,
1327 0x00000000FDFDFDFDULL,
1328 0x0000000000FDFDFDULL,
1329 0x000000000000FDFDULL
1330 },
1331 {
1332 0xFDFDFDFDFDFDFDFDULL,
1333 0xFDFDFDFDFDFDFDFDULL,
1334 0xFDFDFDFDFDFDFDFDULL,
1335 0x00FDFDFDFDFDFDFDULL,
1336 0x0000FDFDFDFDFDFDULL,
1337 0x000000FDFDFDFDFDULL,
1338 0x00000000FDFDFDFDULL,
1339 0x0000000000FDFDFDULL
1340 },
1341 {
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0xFDFDFDFDFDFDFDFDULL,
1344 0xFDFDFDFDFDFDFDFDULL,
1345 0xFDFDFDFDFDFDFDFDULL,
1346 0x00FDFDFDFDFDFDFDULL,
1347 0x0000FDFDFDFDFDFDULL,
1348 0x000000FDFDFDFDFDULL,
1349 0x00000000FDFDFDFDULL
1350 },
1351 {
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0xFDFDFDFDFDFDFDFDULL,
1355 0xFDFDFDFDFDFDFDFDULL,
1356 0xFDFDFDFDFDFDFDFDULL,
1357 0x00FDFDFDFDFDFDFDULL,
1358 0x0000FDFDFDFDFDFDULL,
1359 0x000000FDFDFDFDFDULL
1360 },
1361 {
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0xFDFDFDFDFDFDFDFDULL,
1366 0xFDFDFDFDFDFDFDFDULL,
1367 0xFDFDFDFDFDFDFDFDULL,
1368 0x00FDFDFDFDFDFDFDULL,
1369 0x0000FDFDFDFDFDFDULL
1370 },
1371 {
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0xFDFDFDFDFDFDFDFDULL,
1377 0xFDFDFDFDFDFDFDFDULL,
1378 0xFDFDFDFDFDFDFDFDULL,
1379 0x00FDFDFDFDFDFDFDULL
1380 },
1381 {
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL,
1387 0xFDFDFDFDFDFDFDFDULL,
1388 0xFDFDFDFDFDFDFDFDULL,
1389 0xFDFDFDFDFDFDFDFDULL
1390 }
1391 },
1392 {
1393 {
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL,
1399 0x0000000000000000ULL,
1400 0x0000000000000000ULL,
1401 0x0000000000000000ULL
1402 },
1403 {
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0x0000000000000000ULL,
1408 0x0000000000000000ULL,
1409 0x0000000000000000ULL,
1410 0x0000000000000000ULL,
1411 0xFD00000000000000ULL
1412 },
1413 {
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0x0000000000000000ULL,
1418 0x0000000000000000ULL,
1419 0x0000000000000000ULL,
1420 0xFD00000000000000ULL,
1421 0xFDFD000000000000ULL
1422 },
1423 {
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL,
1429 0xFD00000000000000ULL,
1430 0xFDFD000000000000ULL,
1431 0xFDFDFD0000000000ULL
1432 },
1433 {
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0x0000000000000000ULL,
1438 0xFD00000000000000ULL,
1439 0xFDFD000000000000ULL,
1440 0xFDFDFD0000000000ULL,
1441 0xFDFDFDFD00000000ULL
1442 },
1443 {
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0xFD00000000000000ULL,
1448 0xFDFD000000000000ULL,
1449 0xFDFDFD0000000000ULL,
1450 0xFDFDFDFD00000000ULL,
1451 0xFDFDFDFDFD000000ULL
1452 },
1453 {
1454 0x0000000000000000ULL,
1455 0x0000000000000000ULL,
1456 0xFD00000000000000ULL,
1457 0xFDFD000000000000ULL,
1458 0xFDFDFD0000000000ULL,
1459 0xFDFDFDFD00000000ULL,
1460 0xFDFDFDFDFD000000ULL,
1461 0xFDFDFDFDFDFD0000ULL
1462 },
1463 {
1464 0x0000000000000000ULL,
1465 0xFD00000000000000ULL,
1466 0xFDFD000000000000ULL,
1467 0xFDFDFD0000000000ULL,
1468 0xFDFDFDFD00000000ULL,
1469 0xFDFDFDFDFD000000ULL,
1470 0xFDFDFDFDFDFD0000ULL,
1471 0xFDFDFDFDFDFDFD00ULL
1472 },
1473 {
1474 0xFD00000000000000ULL,
1475 0xFDFD000000000000ULL,
1476 0xFDFDFD0000000000ULL,
1477 0xFDFDFDFD00000000ULL,
1478 0xFDFDFDFDFD000000ULL,
1479 0xFDFDFDFDFDFD0000ULL,
1480 0xFDFDFDFDFDFDFD00ULL,
1481 0xFDFDFDFDFDFDFDFDULL
1482 },
1483 {
1484 0xFDFD000000000000ULL,
1485 0xFDFDFD0000000000ULL,
1486 0xFDFDFDFD00000000ULL,
1487 0xFDFDFDFDFD000000ULL,
1488 0xFDFDFDFDFDFD0000ULL,
1489 0xFDFDFDFDFDFDFD00ULL,
1490 0xFDFDFDFDFDFDFDFDULL,
1491 0xFDFDFDFDFDFDFDFDULL
1492 },
1493 {
1494 0xFDFDFD0000000000ULL,
1495 0xFDFDFDFD00000000ULL,
1496 0xFDFDFDFDFD000000ULL,
1497 0xFDFDFDFDFDFD0000ULL,
1498 0xFDFDFDFDFDFDFD00ULL,
1499 0xFDFDFDFDFDFDFDFDULL,
1500 0xFDFDFDFDFDFDFDFDULL,
1501 0xFDFDFDFDFDFDFDFDULL
1502 },
1503 {
1504 0xFDFDFDFD00000000ULL,
1505 0xFDFDFDFDFD000000ULL,
1506 0xFDFDFDFDFDFD0000ULL,
1507 0xFDFDFDFDFDFDFD00ULL,
1508 0xFDFDFDFDFDFDFDFDULL,
1509 0xFDFDFDFDFDFDFDFDULL,
1510 0xFDFDFDFDFDFDFDFDULL,
1511 0xFDFDFDFDFDFDFDFDULL
1512 },
1513 {
1514 0xFDFDFDFDFD000000ULL,
1515 0xFDFDFDFDFDFD0000ULL,
1516 0xFDFDFDFDFDFDFD00ULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL,
1520 0xFDFDFDFDFDFDFDFDULL,
1521 0xFDFDFDFDFDFDFDFDULL
1522 },
1523 {
1524 0xFDFDFDFDFDFD0000ULL,
1525 0xFDFDFDFDFDFDFD00ULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL,
1530 0xFDFDFDFDFDFDFDFDULL,
1531 0xFDFDFDFDFDFDFDFDULL
1532 },
1533 {
1534 0xFDFDFDFDFDFDFD00ULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL,
1540 0xFDFDFDFDFDFDFDFDULL,
1541 0xFDFDFDFDFDFDFDFDULL
1542 },
1543 {
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL,
1550 0xFDFDFDFDFDFDFDFDULL,
1551 0xFDFDFDFDFDFDFDFDULL
1552 }
1553 },
1554 {
1555 {
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL,
1561 0x0000000000000000ULL,
1562 0x0000000000000000ULL,
1563 0x0000000000000000ULL
1564 },
1565 {
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x0000000000000000ULL,
1570 0x0000000000000000ULL,
1571 0x0000000000000000ULL,
1572 0x0000000000000000ULL,
1573 0x00000000000000FDULL
1574 },
1575 {
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x0000000000000000ULL,
1580 0x0000000000000000ULL,
1581 0x0000000000000000ULL,
1582 0x00000000000000FDULL,
1583 0x000000000000FDFDULL
1584 },
1585 {
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL,
1591 0x00000000000000FDULL,
1592 0x000000000000FDFDULL,
1593 0x0000000000FDFDFDULL
1594 },
1595 {
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x0000000000000000ULL,
1600 0x00000000000000FDULL,
1601 0x000000000000FDFDULL,
1602 0x0000000000FDFDFDULL,
1603 0x00000000FDFDFDFDULL
1604 },
1605 {
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x00000000000000FDULL,
1610 0x000000000000FDFDULL,
1611 0x0000000000FDFDFDULL,
1612 0x00000000FDFDFDFDULL,
1613 0x000000FDFDFDFDFDULL
1614 },
1615 {
1616 0x0000000000000000ULL,
1617 0x0000000000000000ULL,
1618 0x00000000000000FDULL,
1619 0x000000000000FDFDULL,
1620 0x0000000000FDFDFDULL,
1621 0x00000000FDFDFDFDULL,
1622 0x000000FDFDFDFDFDULL,
1623 0x0000FDFDFDFDFDFDULL
1624 },
1625 {
1626 0x0000000000000000ULL,
1627 0x00000000000000FDULL,
1628 0x000000000000FDFDULL,
1629 0x0000000000FDFDFDULL,
1630 0x00000000FDFDFDFDULL,
1631 0x000000FDFDFDFDFDULL,
1632 0x0000FDFDFDFDFDFDULL,
1633 0x00FDFDFDFDFDFDFDULL
1634 },
1635 {
1636 0x00000000000000FDULL,
1637 0x000000000000FDFDULL,
1638 0x0000000000FDFDFDULL,
1639 0x00000000FDFDFDFDULL,
1640 0x000000FDFDFDFDFDULL,
1641 0x0000FDFDFDFDFDFDULL,
1642 0x00FDFDFDFDFDFDFDULL,
1643 0xFDFDFDFDFDFDFDFDULL
1644 },
1645 {
1646 0x000000000000FDFDULL,
1647 0x0000000000FDFDFDULL,
1648 0x00000000FDFDFDFDULL,
1649 0x000000FDFDFDFDFDULL,
1650 0x0000FDFDFDFDFDFDULL,
1651 0x00FDFDFDFDFDFDFDULL,
1652 0xFDFDFDFDFDFDFDFDULL,
1653 0xFDFDFDFDFDFDFDFDULL
1654 },
1655 {
1656 0x0000000000FDFDFDULL,
1657 0x00000000FDFDFDFDULL,
1658 0x000000FDFDFDFDFDULL,
1659 0x0000FDFDFDFDFDFDULL,
1660 0x00FDFDFDFDFDFDFDULL,
1661 0xFDFDFDFDFDFDFDFDULL,
1662 0xFDFDFDFDFDFDFDFDULL,
1663 0xFDFDFDFDFDFDFDFDULL
1664 },
1665 {
1666 0x00000000FDFDFDFDULL,
1667 0x000000FDFDFDFDFDULL,
1668 0x0000FDFDFDFDFDFDULL,
1669 0x00FDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL,
1672 0xFDFDFDFDFDFDFDFDULL,
1673 0xFDFDFDFDFDFDFDFDULL
1674 },
1675 {
1676 0x000000FDFDFDFDFDULL,
1677 0x0000FDFDFDFDFDFDULL,
1678 0x00FDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL,
1682 0xFDFDFDFDFDFDFDFDULL,
1683 0xFDFDFDFDFDFDFDFDULL
1684 },
1685 {
1686 0x0000FDFDFDFDFDFDULL,
1687 0x00FDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL,
1692 0xFDFDFDFDFDFDFDFDULL,
1693 0xFDFDFDFDFDFDFDFDULL
1694 },
1695 {
1696 0x00FDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL,
1702 0xFDFDFDFDFDFDFDFDULL,
1703 0xFDFDFDFDFDFDFDFDULL
1704 },
1705 {
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL,
1712 0xFDFDFDFDFDFDFDFDULL,
1713 0xFDFDFDFDFDFDFDFDULL
1714 }
1715 }
1716 };
1717
1718 int32_t black_opening_count=0;
1719 int32_t black_opening_x,black_opening_y;
1720 int32_t black_opening_shape;
1721
1722 1504 int32_t choose_opening_shape()
1723 {
1724 // First, count how many bits are set
1725 1504 int32_t numBits=0;
1726 int32_t bitCounter;
1727
1728
2/2
✓ Branch 0 taken 7520 times.
✓ Branch 1 taken 1504 times.
9024 for(int32_t i=0; i<bosMAX; i++)
1729 {
1730
2/2
✓ Branch 0 taken 5800 times.
✓ Branch 1 taken 1720 times.
7520 if(COOLSCROLL&(1<<i))
1731 1720 numBits++;
1732 7520 }
1733
1734 // Shouldn't happen...
1735
1/2
✓ Branch 0 taken 1504 times.
✗ Branch 1 not taken.
1504 if(numBits==0)
1736 return bosCIRCLE;
1737
1738 // Pick a bit
1739 1504 bitCounter=zc_rand()%numBits+1;
1740
1741
2/2
✓ Branch 0 taken 1987 times.
✓ Branch 1 taken 26 times.
2013 for(int32_t i=0; i<bosMAX; i++)
1742 {
1743 // If this bit is set, decrement the bit counter
1744
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 1634 times.
1987 if(COOLSCROLL&(1<<i))
1745 1634 bitCounter--;
1746
1747 // When the counter hits 0, return a value based on
1748 // which bit it stopped on.
1749 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1750
2/2
✓ Branch 0 taken 1478 times.
✓ Branch 1 taken 509 times.
1987 if(bitCounter==0)
1751 1478 return i;
1752 509 }
1753
1754 // Shouldn't be necessary, but the compiler might complain, at least
1755 26 return bosCIRCLE;
1756 1504 }
1757
1758 396 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1759 {
1760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1761
1762 396 int32_t w=256, h=224;
1763 396 int32_t blockrows=28, blockcolumns=32;
1764 396 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1765
1766
2/2
✓ Branch 0 taken 11088 times.
✓ Branch 1 taken 396 times.
11484 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1767 {
1768
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 11088 times.
365904 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1769 {
1770
2/2
✓ Branch 0 taken 147229 times.
✓ Branch 1 taken 207587 times.
354816 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1771 354816 }
1772 11088 }
1773
1774 396 black_opening_count = 66;
1775 396 black_opening_x = x;
1776 396 black_opening_y = y;
1777 396 lensclk = 0;
1778 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1779
1780
1781
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(black_opening_shape == bosFADEBLACK)
1782 {
1783 refreshTints();
1784 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1785 }
1786
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(wait)
1787 {
1788 FFCore.warpScriptCheck();
1789 for(int32_t i=0; i<66; i++)
1790 {
1791 draw_screen(tmpscr);
1792 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1793 advanceframe(true);
1794
1795 if(Quit)
1796 {
1797 break;
1798 }
1799 }
1800 }
1801 396 }
1802
1803 1108 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1804 {
1805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1108 times.
1108 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1806
1807 1108 int32_t w=256, h=224;
1808 1108 int32_t blockrows=28, blockcolumns=32;
1809 1108 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1810
1811
2/2
✓ Branch 0 taken 31024 times.
✓ Branch 1 taken 1108 times.
32132 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1812 {
1813
2/2
✓ Branch 0 taken 992768 times.
✓ Branch 1 taken 31024 times.
1023792 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1814 {
1815
2/2
✓ Branch 0 taken 505454 times.
✓ Branch 1 taken 487314 times.
992768 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1816 992768 }
1817 31024 }
1818
1819 1108 black_opening_count = -66;
1820 1108 black_opening_x = x;
1821 1108 black_opening_y = y;
1822 1108 lensclk = 0;
1823
1/2
✓ Branch 0 taken 1108 times.
✗ Branch 1 not taken.
1108 if(black_opening_shape == bosFADEBLACK)
1824 {
1825 refreshTints();
1826 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1827 }
1828
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 909 times.
1108 if(wait)
1829 {
1830 909 FFCore.warpScriptCheck();
1831
2/2
✓ Branch 0 taken 909 times.
✓ Branch 1 taken 59994 times.
60903 for(int32_t i=0; i<66; i++)
1832 {
1833 59994 draw_screen(tmpscr);
1834 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1835 59994 advanceframe(true);
1836
1837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59994 times.
59994 if(Quit)
1838 {
1839 break;
1840 }
1841 59994 }
1842 909 }
1843 1108 }
1844
1845 99264 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1846 {
1847 99264 clear_to_color(tmp_scr,BLACK);
1848 99264 int32_t w=256, h=224;
1849
1850
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 594 times.
✓ Branch 3 taken 7656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90156 times.
99264 switch(black_opening_shape)
1851 {
1852 case bosOVAL:
1853 {
1854 858 double new_w=(w/2)+abs(w/2-x);
1855 858 double new_h=(h/2)+abs(h/2-y);
1856 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1857 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1858 858 break;
1859 }
1860
1861 case bosTRIANGLE:
1862 {
1863 594 double new_w=(w/2)+abs(w/2-x);
1864 594 double new_h=(h/2)+abs(h/2-y);
1865 594 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1866 594 double P2= (PI/2);
1867 594 double P23=(2*PI/3);
1868 594 double P43=(4*PI/3);
1869 594 double Pa= (-4*PI*a/(3*max_a));
1870 594 double angle=P2+Pa;
1871 594 double a0=angle;
1872 594 double a2=angle+P23;
1873 594 double a4=angle+P43;
1874 1188 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1875 594 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1876 594 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1877 0);
1878 594 break;
1879 }
1880
1881 case bosSMAS:
1882 {
1883
2/2
✓ Branch 0 taken 4158 times.
✓ Branch 1 taken 3498 times.
7656 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1884
1885
2/2
✓ Branch 0 taken 214368 times.
✓ Branch 1 taken 7656 times.
222024 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1886 {
1887
2/2
✓ Branch 0 taken 1714944 times.
✓ Branch 1 taken 214368 times.
1929312 for(int32_t linerow=0; linerow<8; ++linerow)
1888 {
1889 1714944 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1890
1891
2/2
✓ Branch 0 taken 54878208 times.
✓ Branch 1 taken 1714944 times.
56593152 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1892 {
1893 164634624 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1894
6/6
✓ Branch 0 taken 39546648 times.
✓ Branch 1 taken 15331560 times.
✓ Branch 2 taken 35934032 times.
✓ Branch 3 taken 18944176 times.
✓ Branch 4 taken 20602472 times.
✓ Branch 5 taken 15331560 times.
54878208 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1895 54878208 [linerow];
1896 54878208 ++triangleline;
1897
1898
2/2
✓ Branch 0 taken 48018432 times.
✓ Branch 1 taken 6859776 times.
54878208 if(linerow==0)
1899 {
1900 6859776 }
1901 54878208 }
1902 1714944 }
1903 214368 }
1904
1905 7656 break;
1906 }
1907
1908 case bosFADEBLACK:
1909 {
1910 if(black_opening_count<0)
1911 {
1912 black_fade(zc_min(-black_opening_count,63));
1913 }
1914 else if(black_opening_count>0)
1915 {
1916 black_fade(63-zc_max(black_opening_count-3,0));
1917 }
1918 else black_fade(0);
1919 return; //no blitting from tmp_scr!
1920 }
1921
1922 90156 case bosCIRCLE:
1923 default:
1924 {
1925 90156 double new_w=(w/2)+abs(w/2-x);
1926 90156 double new_h=(h/2)+abs(h/2-y);
1927 90156 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1928 //circlefill(tmp_scr,x,y,a<<3,0);
1929 90156 circlefill(tmp_scr,x,y,r,0);
1930 90156 break;
1931 }
1932 }
1933
1934 99264 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1935 99264 }
1936
1937
1938 void black_fade(int32_t fadeamnt)
1939 {
1940 for(int32_t i=0; i < 0xEF; i++)
1941 {
1942 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1943 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1944 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1945 }
1946
1947 refreshpal = true;
1948 }
1949
1950 //----------------------------------------------------------------
1951
1952 44438520 bool item_disabled(int32_t item) //is this item disabled?
1953 {
1954
2/2
✓ Branch 0 taken 1796289 times.
✓ Branch 1 taken 42642231 times.
44438520 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1955 }
1956
1957 7617110 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1958 {
1959
2/2
✓ Branch 0 taken 135210 times.
✓ Branch 1 taken 7481900 times.
7617110 if(current_item(item_type, true) >=item)
1960 {
1961 135210 return true;
1962 }
1963
1964 7481900 return false;
1965 7617110 }
1966
1967 31050486 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1968 {
1969
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6052346 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3220277 times.
✓ Branch 6 taken 16168678 times.
✓ Branch 7 taken 5493498 times.
✓ Branch 8 taken 115687 times.
31050486 switch(item_type)
1970 {
1971 case itype_bomb:
1972 case itype_sbomb:
1973 {
1974 int32_t itemid = getItemID(itemsbuf, item_type, it);
1975
1976 if(itemid == -1)
1977 return false;
1978
1979 return (game->get_item(itemid));
1980 }
1981
1982 case itype_clock:
1983 {
1984 6052346 int32_t itemid = getItemID(itemsbuf, item_type, it);
1985
1986
2/4
✓ Branch 0 taken 6052346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6052346 times.
✗ Branch 3 not taken.
6052346 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1987 return (game->get_item(itemid));
1988 6052346 return Hero.getClock()?1:0;
1989 }
1990
1991 case itype_key:
1992 return (game->get_keys()>0);
1993
1994 case itype_magiccontainer:
1995 return (game->get_maxmagic()>=game->get_mp_per_block());
1996
1997 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1998 {
1999
1/3
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3220277 switch(it)
2000 {
2001 case -2:
2002 {
2003 for(int32_t i=0; i<MAXLEVELS; i++)
2004 {
2005 if(game->lvlitems[i]&liTRIFORCE)
2006 {
2007 return true;
2008 }
2009 }
2010
2011 return false;
2012 }
2013
2014 case -1:
2015 return (game->lvlitems[dlevel]&liTRIFORCE);
2016
2017 default:
2018
2/4
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3220277 times.
3220277 if(it>=0&&it<MAXLEVELS)
2019 {
2020 3220277 return (game->lvlitems[it]&liTRIFORCE);
2021 }
2022
2023 break;
2024 }
2025
2026 return 0;
2027 }
2028
2029 case itype_map: //it: -2=any, -1=current level, other=that level
2030 {
2031
1/3
✓ Branch 0 taken 16168678 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
16168678 switch(it)
2032 {
2033 case -2:
2034 {
2035 for(int32_t i=0; i<MAXLEVELS; i++)
2036 {
2037 if(game->lvlitems[i]&liMAP)
2038 {
2039 return true;
2040 }
2041 }
2042
2043 return false;
2044 }
2045
2046 case -1:
2047 return (game->lvlitems[dlevel]&liMAP)!=0;
2048
2049 default:
2050
2/4
✓ Branch 0 taken 16168678 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16168678 times.
16168678 if(it>=0&&it<MAXLEVELS)
2051 {
2052 16168678 return (game->lvlitems[it]&liMAP)!=0;
2053 }
2054
2055 break;
2056 }
2057
2058 return 0;
2059 }
2060
2061 case itype_compass: //it: -2=any, -1=current level, other=that level
2062 {
2063
1/3
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5493498 switch(it)
2064 {
2065 case -2:
2066 {
2067 for(int32_t i=0; i<MAXLEVELS; i++)
2068 {
2069 if(game->lvlitems[i]&liCOMPASS)
2070 {
2071 return true;
2072 }
2073 }
2074
2075 return false;
2076 }
2077
2078 case -1:
2079 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2080
2081 default:
2082
2/4
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5493498 times.
✗ Branch 3 not taken.
5493498 if(it>=0&&it<MAXLEVELS)
2083 {
2084 5493498 return (game->lvlitems[it]&liCOMPASS)!=0;
2085 }
2086
2087 break;
2088 }
2089 return 0;
2090 }
2091
2092 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2093 {
2094
1/3
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
115687 switch(it)
2095 {
2096 case -2:
2097 {
2098 for(int32_t i=0; i<MAXLEVELS; i++)
2099 {
2100 if(game->lvlitems[i]&liBOSSKEY)
2101 {
2102 return true;
2103 }
2104 }
2105
2106 return false;
2107 }
2108
2109 case -1:
2110 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2111
2112 default:
2113
2/4
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115687 times.
115687 if(it>=0&&it<MAXLEVELS)
2114 {
2115 115687 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2116 }
2117 break;
2118 }
2119 return 0;
2120 }
2121
2122 default:
2123 //it=(1<<(it-1));
2124 /*if (item_type>=itype_max)
2125 {
2126 enter_sys_pal();
2127 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2128 exit_sys_pal();
2129
2130 return false;
2131 }*/
2132 int32_t itemid = getItemID(itemsbuf, item_type, it);
2133
2134 if(itemid == -1)
2135 return false;
2136
2137 return game->get_item(itemid);
2138 }
2139 31050486 }
2140
2141
2142 99999365 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2143 {
2144
9/9
✓ Branch 0 taken 6052346 times.
✓ Branch 1 taken 51580597 times.
✓ Branch 2 taken 6052346 times.
✓ Branch 3 taken 6052346 times.
✓ Branch 4 taken 6052346 times.
✓ Branch 5 taken 6052346 times.
✓ Branch 6 taken 6052346 times.
✓ Branch 7 taken 6052346 times.
✓ Branch 8 taken 6052346 times.
99999365 switch(item_type)
2145 {
2146 case itype_clock:
2147 {
2148 6052346 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2149
2150
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6052346 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6052346 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2151 return itemsbuf[maxid].fam_type;
2152
2153 6052346 return has_item(itype_clock,1) ? 1 : 0;
2154 }
2155
2156 case itype_key:
2157 6052346 return game->get_keys();
2158
2159 case itype_lkey:
2160 6052346 return game->lvlkeys[get_dlevel()];
2161
2162 case itype_magiccontainer:
2163 6052346 return game->get_maxmagic()/game->get_mp_per_block();
2164
2165 case itype_triforcepiece:
2166 {
2167 6052346 int32_t count=0;
2168
2169
2/2
✓ Branch 0 taken 3098801152 times.
✓ Branch 1 taken 6052346 times.
3104853498 for(int32_t i=0; i<MAXLEVELS; i++)
2170 {
2171 3098801152 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2172 3098801152 }
2173
2174 6052346 return count;
2175 }
2176
2177 case itype_map:
2178 {
2179 6052346 int32_t count=0;
2180
2181
2/2
✓ Branch 0 taken 3098801152 times.
✓ Branch 1 taken 6052346 times.
3104853498 for(int32_t i=0; i<MAXLEVELS; i++)
2182 {
2183 3098801152 count+=(game->lvlitems[i]&liMAP)?1:0;
2184 3098801152 }
2185
2186 6052346 return count;
2187 }
2188
2189 case itype_compass:
2190 {
2191 6052346 int32_t count=0;
2192
2193
2/2
✓ Branch 0 taken 3098801152 times.
✓ Branch 1 taken 6052346 times.
3104853498 for(int32_t i=0; i<MAXLEVELS; i++)
2194 {
2195 3098801152 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2196 3098801152 }
2197
2198 6052346 return count;
2199 }
2200
2201 case itype_bosskey:
2202 {
2203 6052346 int32_t count=0;
2204
2205
2/2
✓ Branch 0 taken 3098801152 times.
✓ Branch 1 taken 6052346 times.
3104853498 for(int32_t i=0; i<MAXLEVELS; i++)
2206 {
2207 3098801152 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2208 3098801152 }
2209
2210 6052346 return count;
2211 }
2212
2213 default:
2214 51580597 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2215
2216
2/2
✓ Branch 0 taken 9872037 times.
✓ Branch 1 taken 41708560 times.
51580597 if(maxid == -1)
2217 41708560 return 0;
2218
2219 9872037 return itemsbuf[maxid].fam_type;
2220 }
2221 99999365 }
2222
2223 92382255 int32_t current_item(int32_t item_type) //item currently being used
2224 {
2225 92382255 return current_item(item_type, true);
2226 }
2227
2228 114 std::map<int32_t, int32_t> itemcache;
2229 114 std::map<int32_t, int32_t> itemcache_cost;
2230
2231 void removeFromItemCache(int32_t itemclass)
2232 {
2233 itemcache.erase(itemclass);
2234 itemcache_cost.erase(itemclass);
2235 }
2236
2237 5855776 void flushItemCache(bool justcost)
2238 {
2239 5855776 itemcache_cost.clear();
2240
2/2
✓ Branch 0 taken 5825866 times.
✓ Branch 1 taken 29910 times.
5855776 if(!justcost)
2241 29910 itemcache.clear();
2242
2/2
✓ Branch 0 taken 5825767 times.
✓ Branch 1 taken 99 times.
5825866 else if(replay_version_check(0,19))
2243 5825767 return;
2244
2245 //also fix the active subscreen if items were deleted -DD
2246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30009 times.
30009 if(game != NULL)
2247 {
2248 30009 verifyBothWeapons();
2249 30009 refresh_subscr_items();
2250 30009 }
2251 5855776 }
2252
2253 // This is used often, so it should be as direct as possible.
2254 3375643303 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2255 {
2256 3375643303 bool use_cost_cache = replay_version_check(19);
2257
2/2
✓ Branch 0 taken 3300087247 times.
✓ Branch 1 taken 75556056 times.
3375643303 if(jinx_check)
2258 {
2259
4/4
✓ Branch 0 taken 47349710 times.
✓ Branch 1 taken 28206346 times.
✓ Branch 2 taken 8273866 times.
✓ Branch 3 taken 39075844 times.
75556056 if(!(HeroSwordClk() || HeroItemClk()))
2260 39075844 jinx_check = false; //not jinxed
2261 75556056 }
2262
2/2
✓ Branch 0 taken 1047446 times.
✓ Branch 1 taken 3374595857 times.
3375643303 if(!Hero.BunnyClock())
2263 3374595857 check_bunny = false; //not bunnied
2264
2/2
✓ Branch 0 taken 3346042094 times.
✓ Branch 1 taken 29601209 times.
3375643303 if(itemtype == itype_ring) checkmagic = true;
2265
4/4
✓ Branch 0 taken 3339163091 times.
✓ Branch 1 taken 36480212 times.
✓ Branch 2 taken 3307822789 times.
✓ Branch 3 taken 29252186 times.
6712718278 if (!jinx_check && !check_bunny
2266
3/4
✓ Branch 0 taken 3339163091 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3337074975 times.
✓ Branch 3 taken 2088116 times.
3339163091 && (use_cost_cache || itemtype != itype_ring))
2267 {
2268
4/4
✓ Branch 0 taken 185293381 times.
✓ Branch 1 taken 3124617524 times.
✓ Branch 2 taken 185107070 times.
✓ Branch 3 taken 186311 times.
3309910905 auto& cache = checkmagic && use_cost_cache ? itemcache_cost : itemcache;
2269 3309910905 auto res = cache.find(itemtype);
2270
2271
2/2
✓ Branch 0 taken 3294646165 times.
✓ Branch 1 taken 15264740 times.
3309910905 if(res != cache.end())
2272 3294646165 return res->second;
2273 15264740 }
2274
2275 80997138 int32_t result = -1;
2276 80997138 int32_t highestlevel = -1;
2277
2278
2/2
✓ Branch 0 taken 20735267328 times.
✓ Branch 1 taken 80997138 times.
20816264466 for(int32_t i=0; i<MAXITEMS; i++)
2279 {
2280
5/6
✓ Branch 0 taken 1520697647 times.
✓ Branch 1 taken 19214569681 times.
✓ Branch 2 taken 21878539 times.
✓ Branch 3 taken 1498819108 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21878539 times.
20735267328 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2281 {
2282
4/4
✓ Branch 0 taken 20037103 times.
✓ Branch 1 taken 1841436 times.
✓ Branch 2 taken 8694 times.
✓ Branch 3 taken 20028409 times.
21878539 if(checkmagic && itemtype != itype_magicring)
2283
2/2
✓ Branch 0 taken 20028239 times.
✓ Branch 1 taken 170 times.
20028409 if(!checkmagiccost(i))
2284 170 continue;
2285
6/6
✓ Branch 0 taken 18586112 times.
✓ Branch 1 taken 3292257 times.
✓ Branch 2 taken 243036 times.
✓ Branch 3 taken 3049221 times.
✓ Branch 4 taken 1846133 times.
✓ Branch 5 taken 1446124 times.
21878369 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1446124 times.
1446124 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2287 1446124 continue;
2288
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20432245 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20432245 if(check_bunny && !checkbunny(i))
2289 continue;
2290
2291
2/2
✓ Branch 0 taken 280080 times.
✓ Branch 1 taken 20152165 times.
20432245 if(itemsbuf[i].fam_type >= highestlevel)
2292 {
2293 20152165 highestlevel = itemsbuf[i].fam_type;
2294 20152165 result=i;
2295 20152165 }
2296 20432245 }
2297 20733821034 }
2298
2299
3/4
✓ Branch 0 taken 44516926 times.
✓ Branch 1 taken 36480212 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44516926 times.
80997138 if(!(jinx_check || check_bunny)) //Can't cache jinx_check/check_bunny
2300 {
2301
2/2
✓ Branch 0 taken 2514 times.
✓ Branch 1 taken 44514412 times.
44516926 if (use_cost_cache)
2302 {
2303
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 1620 times.
2514 if (!checkmagic)
2304 1620 itemcache[itemtype] = result;
2305
5/6
✓ Branch 0 taken 1620 times.
✓ Branch 1 taken 894 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1617 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
2514 if (checkmagic || result < 0 || checkmagiccost(result))
2306 2514 itemcache_cost[itemtype] = result;
2307 2514 }
2308 else
2309 {
2310 44514412 itemcache[itemtype] = result;
2311 }
2312 44516926 }
2313 80997138 return result;
2314 3375643303 }
2315
2316 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2317 3339607304 int32_t current_item_id(int32_t itype, bool checkmagic, bool jinx_check, bool check_bunny)
2318 {
2319
2/4
✓ Branch 0 taken 3339607304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3339607304 times.
3339607304 if(itype < 0 || itype >= itype_max) return -1;
2320
1/2
✓ Branch 0 taken 3339607304 times.
✗ Branch 1 not taken.
3339607304 if(game->OverrideItems[itype] > -2)
2321 {
2322 auto ovid = game->OverrideItems[itype];
2323 if(ovid < 0 || ovid >= MAXITEMS)
2324 return -1;
2325 if(itemsbuf[ovid].family == itype)
2326 {
2327 if(itype == itype_magicring)
2328 checkmagic = false;
2329 else if(itype == itype_ring)
2330 checkmagic = true;
2331
2332 if(checkmagic && !checkmagiccost(ovid))
2333 return -1;
2334 if(jinx_check && !(itemsbuf[ovid].flags & ITEM_JINX_IMMUNE)
2335 && (usesSwordJinx(ovid) ? HeroSwordClk() : HeroItemClk()))
2336 return -1;
2337 return ovid;
2338 }
2339 }
2340 3339607304 auto ret = _c_item_id_internal(itype,checkmagic,jinx_check,check_bunny);
2341
2/2
✓ Branch 0 taken 39520057 times.
✓ Branch 1 taken 3300087247 times.
3339607304 if(!jinx_check) //If not already a jinx-immune-only check...
2342 {
2343 //And the player IS jinxed...
2344
4/4
✓ Branch 0 taken 3272223878 times.
✓ Branch 1 taken 27863369 times.
✓ Branch 2 taken 8172630 times.
✓ Branch 3 taken 3264051248 times.
3300087247 if(HeroSwordClk() || HeroItemClk())
2345 {
2346 //Then do a jinx-immune-only check here
2347 36035999 auto ret2 = _c_item_id_internal(itype,checkmagic,true,check_bunny);
2348 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2349 //Should NOT need a compat rule, as this should always return -1 in old quests.
2350
2/2
✓ Branch 0 taken 1261308 times.
✓ Branch 1 taken 34774691 times.
36035999 if(ret2 > -1) return ret2;
2351 34774691 }
2352 3298825939 }
2353 3338345996 return ret;
2354 3339607304 }
2355
2356 19332554 int32_t current_item_power(int32_t itemtype)
2357 {
2358 19332554 int32_t result = current_item_id(itemtype,true);
2359
2/2
✓ Branch 0 taken 14039846 times.
✓ Branch 1 taken 5292708 times.
19332554 return (result<0) ? 0 : itemsbuf[result].power;
2360 }
2361
2362 11 int32_t heart_container_id()
2363 {
2364
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 for(int32_t i=0; i<MAXITEMS; i++)
2365 {
2366
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 308 times.
319 if(itemsbuf[i].family == itype_heartcontainer)
2367 {
2368 11 return i;
2369 }
2370 308 }
2371 return -1;
2372 11 }
2373
2374 6052346 int32_t item_tile_mod()
2375 {
2376 6052346 int32_t tile=0;
2377
2378
2/2
✓ Branch 0 taken 1206121 times.
✓ Branch 1 taken 4846225 times.
6052346 if(game->get_bombs())
2379 {
2380 4846225 int32_t itemid = current_item_id(itype_bomb,false);
2381
3/4
✓ Branch 0 taken 4681056 times.
✓ Branch 1 taken 165169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4681056 times.
4846225 if(itemid > -1 && checkbunny(itemid))
2382 4681056 tile+=itemsbuf[itemid].ltm;
2383 4846225 }
2384
2385
2/2
✓ Branch 0 taken 4539056 times.
✓ Branch 1 taken 1513290 times.
6052346 if(game->get_sbombs())
2386 {
2387 1513290 int32_t itemid = current_item_id(itype_sbomb,false);
2388
3/4
✓ Branch 0 taken 1511862 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1511862 times.
1513290 if(itemid > -1 && checkbunny(itemid))
2389 1511862 tile+=itemsbuf[itemid].ltm;
2390 1513290 }
2391
2392
2/2
✓ Branch 0 taken 5942646 times.
✓ Branch 1 taken 109700 times.
6052346 if(current_item(itype_clock))
2393 {
2394 109700 int32_t itemid =
2395
1/2
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
109700 get_qr(qr_HARDCODED_LITEM_LTMS)
2396 ? iClock
2397 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2398
2/4
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109700 times.
109700 if(itemid > -1 && checkbunny(itemid))
2399 109700 tile+=itemsbuf[itemid].ltm;
2400 109700 }
2401
2402
2/2
✓ Branch 0 taken 4671605 times.
✓ Branch 1 taken 1380741 times.
6052346 if(current_item(itype_key))
2403 {
2404 1380741 int32_t itemid =
2405
1/2
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
1380741 get_qr(qr_HARDCODED_LITEM_LTMS)
2406 ? iKey
2407 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2408
2/4
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1380741 times.
1380741 if(itemid > -1 && checkbunny(itemid))
2409 1380741 tile+=itemsbuf[itemid].ltm;
2410 1380741 }
2411
2412
2/2
✓ Branch 0 taken 5785243 times.
✓ Branch 1 taken 267103 times.
6052346 if(current_item(itype_lkey))
2413 {
2414 267103 int32_t itemid =
2415
2/2
✓ Branch 0 taken 266193 times.
✓ Branch 1 taken 910 times.
267103 get_qr(qr_HARDCODED_LITEM_LTMS)
2416 ? iLevelKey
2417 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2418
2/4
✓ Branch 0 taken 267103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 267103 times.
267103 if(itemid > -1 && checkbunny(itemid))
2419 267103 tile+=itemsbuf[itemid].ltm;
2420 267103 }
2421
2422
2/2
✓ Branch 0 taken 1256315 times.
✓ Branch 1 taken 4796031 times.
6052346 if(current_item(itype_map))
2423 {
2424 4796031 int32_t itemid =
2425
1/2
✓ Branch 0 taken 4796031 times.
✗ Branch 1 not taken.
4796031 get_qr(qr_HARDCODED_LITEM_LTMS)
2426 ? iMap
2427 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2428
2/4
✓ Branch 0 taken 4796031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4796031 times.
4796031 if(itemid > -1 && checkbunny(itemid))
2429 4796031 tile+=itemsbuf[itemid].ltm;
2430 4796031 }
2431
2432
2/2
✓ Branch 0 taken 1233647 times.
✓ Branch 1 taken 4818699 times.
6052346 if(current_item(itype_compass))
2433 {
2434 4818699 int32_t itemid =
2435
2/2
✓ Branch 0 taken 4737640 times.
✓ Branch 1 taken 81059 times.
4818699 get_qr(qr_HARDCODED_LITEM_LTMS)
2436 ? iCompass
2437 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2438
2/4
✓ Branch 0 taken 4818699 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4818699 times.
4818699 if(itemid > -1 && checkbunny(itemid))
2439 4818699 tile+=itemsbuf[itemid].ltm;
2440 4818699 }
2441
2442
2/2
✓ Branch 0 taken 3421801 times.
✓ Branch 1 taken 2630545 times.
6052346 if(current_item(itype_bosskey))
2443 {
2444 2630545 int32_t itemid =
2445
1/2
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
2630545 get_qr(qr_HARDCODED_LITEM_LTMS)
2446 ? iBossKey
2447 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2448
2/4
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2630545 times.
2630545 if(itemid > -1 && checkbunny(itemid))
2449 2630545 tile+=itemsbuf[itemid].ltm;
2450 2630545 }
2451
2452
2/2
✓ Branch 0 taken 2919156 times.
✓ Branch 1 taken 3133190 times.
6052346 if(current_item(itype_magiccontainer))
2453 {
2454 3133190 int32_t itemid =
2455
2/2
✓ Branch 0 taken 3040989 times.
✓ Branch 1 taken 92201 times.
3133190 get_qr(qr_HARDCODED_LITEM_LTMS)
2456 ? iMagicC
2457 92201 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2458
3/4
✓ Branch 0 taken 3133190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 3131320 times.
3133190 if(itemid > -1 && checkbunny(itemid))
2459 3131320 tile+=itemsbuf[itemid].ltm;
2460 3133190 }
2461
2462
2/2
✓ Branch 0 taken 1591712 times.
✓ Branch 1 taken 4460634 times.
6052346 if(current_item(itype_triforcepiece))
2463 {
2464 4460634 int32_t itemid =
2465
1/2
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
4460634 get_qr(qr_HARDCODED_LITEM_LTMS)
2466 ? iTriforce
2467 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2468
2/4
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4460634 times.
4460634 if(itemid > -1 && checkbunny(itemid))
2469 4460634 tile+=itemsbuf[itemid].ltm;
2470 4460634 }
2471
2472
2/2
✓ Branch 0 taken 6052346 times.
✓ Branch 1 taken 3098801152 times.
3104853498 for(int32_t i=0; i<itype_max; i++)
2473 {
2474
2/2
✓ Branch 0 taken 3042451456 times.
✓ Branch 1 taken 56349696 times.
3098801152 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2475 {
2476
2/2
✓ Branch 0 taken 1100580 times.
✓ Branch 1 taken 55249116 times.
56349696 switch(i)
2477 {
2478 case itype_bomb:
2479 case itype_sbomb:
2480 case itype_clock:
2481 case itype_key:
2482 case itype_lkey:
2483 case itype_map:
2484 case itype_compass:
2485 case itype_bosskey:
2486 case itype_magiccontainer:
2487 case itype_triforcepiece:
2488 1100580 continue; //already handled
2489 }
2490 55249116 }
2491 3097700572 int32_t itemid = current_item_id(i,false);
2492
2/2
✓ Branch 0 taken 3091648226 times.
✓ Branch 1 taken 6052346 times.
3097700572 if(i == itype_shield)
2493 6052346 itemid = getCurrentShield(false);
2494
2495
4/4
✓ Branch 0 taken 80828213 times.
✓ Branch 1 taken 3016872359 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 80727232 times.
3097700572 if(itemid < 0 || !checkbunny(itemid))
2496 3016973340 continue;
2497
2498 80727232 itemdata const& itm = itemsbuf[itemid];
2499
2500
2/2
✓ Branch 0 taken 75312220 times.
✓ Branch 1 taken 5415012 times.
80727232 switch(itm.family)
2501 {
2502 case itype_shield:
2503
1/2
✓ Branch 0 taken 5415012 times.
✗ Branch 1 not taken.
5415012 if(itm.flags & ITEM_FLAG9) //active shield
2504 {
2505 if(!usingActiveShield(itemid))
2506 {
2507 tile+=itm.misc6; //'Inactive PTM'
2508 continue;
2509 }
2510 }
2511 5415012 break;
2512 }
2513
2514 80727232 tile+=itm.ltm;
2515 80727232 }
2516
2517 6052346 return tile;
2518 }
2519
2520 6052346 int32_t bunny_tile_mod()
2521 {
2522
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 6050476 times.
6052346 if(Hero.BunnyClock())
2523 {
2524 1870 return game->get_bunny_ltm();
2525 }
2526 6050476 return 0;
2527 6052346 }
2528
2529 // Hints are drawn on a separate layer to combo reveals.
2530 16332 void draw_lens_under(BITMAP *dest, bool layer)
2531 {
2532 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2533 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2534 //Lens flag 3: Don't show armos/chest/dive items
2535 //Lens flag 4: Show Raft Paths
2536 //Lens flag 5: Show Invisible Enemies
2537
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2538
2539 16332 int32_t strike_hint_table[11]=
2540 {
2541 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2542 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2543 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2544 };
2545
2546 // int32_t page = tmpscr->cpage;
2547 {
2548 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2549 // int32_t temptimer=0;
2550 16332 int32_t tempitem, tempweapon=0;
2551 16332 strike_hint=strike_hint_table[strike_hint_counter];
2552
2553
2/2
✓ Branch 0 taken 15842 times.
✓ Branch 1 taken 490 times.
16332 if(strike_hint_timer>32)
2554 {
2555 490 strike_hint_timer=0;
2556 490 strike_hint_counter=((strike_hint_counter+1)%11);
2557 490 }
2558
2559 16332 ++strike_hint_timer;
2560
2561
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2562 {
2563 2874432 int32_t x = (i & 15) << 4;
2564 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2565 2874432 int32_t tempitemx=-16, tempitemy=-16;
2566 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2567
2568
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2569 {
2570 5748864 int32_t checkflag=0;
2571
2572
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2573 {
2574 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2575 2874432 }
2576 else
2577 {
2578 2874432 checkflag=tmpscr->sflag[i];
2579 }
2580
2581
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2582 {
2583
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2584 {
2585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2586 906 }
2587 else
2588 {
2589 192 checkflag = strike_hint;
2590 }
2591 1098 }
2592
2593
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2594 {
2595 case 0:
2596 case mfZELDA:
2597 case mfPUSHED:
2598 case mfENEMY0:
2599 case mfENEMY1:
2600 case mfENEMY2:
2601 case mfENEMY3:
2602 case mfENEMY4:
2603 case mfENEMY5:
2604 case mfENEMY6:
2605 case mfENEMY7:
2606 case mfENEMY8:
2607 case mfENEMY9:
2608 case mfSINGLE:
2609 case mfSINGLE16:
2610 case mfNOENEMY:
2611 case mfTRAP_H:
2612 case mfTRAP_V:
2613 case mfTRAP_4:
2614 case mfTRAP_LR:
2615 case mfTRAP_UD:
2616 case mfNOGROUNDENEMY:
2617 case mfNOBLOCKS:
2618 case mfSCRIPT1:
2619 case mfSCRIPT2:
2620 case mfSCRIPT3:
2621 case mfSCRIPT4:
2622 case mfSCRIPT5:
2623 case mfSCRIPT6:
2624 case mfSCRIPT7:
2625 case mfSCRIPT8:
2626 case mfSCRIPT9:
2627 case mfSCRIPT10:
2628 case mfSCRIPT11:
2629 case mfSCRIPT12:
2630 case mfSCRIPT13:
2631 case mfSCRIPT14:
2632 case mfSCRIPT15:
2633 case mfSCRIPT16:
2634 case mfSCRIPT17:
2635 case mfSCRIPT18:
2636 case mfSCRIPT19:
2637 case mfSCRIPT20:
2638 case mfPITHOLE:
2639 case mfPITFALLFLOOR:
2640 case mfLAVA:
2641 case mfICE:
2642 case mfICEDAMAGE:
2643 case mfDAMAGE1:
2644 case mfDAMAGE2:
2645 case mfDAMAGE4:
2646 case mfDAMAGE8:
2647 case mfDAMAGE16:
2648 case mfDAMAGE32:
2649 case mfFREEZEALL:
2650 case mfFREZEALLANSFFCS:
2651 case mfFREEZEFFCSOLY:
2652 case mfSCRITPTW1TRIG:
2653 case mfSCRITPTW2TRIG:
2654 case mfSCRITPTW3TRIG:
2655 case mfSCRITPTW4TRIG:
2656 case mfSCRITPTW5TRIG:
2657 case mfSCRITPTW6TRIG:
2658 case mfSCRITPTW7TRIG:
2659 case mfSCRITPTW8TRIG:
2660 case mfSCRITPTW9TRIG:
2661 case mfSCRITPTW10TRIG:
2662 case mfTROWEL:
2663 case mfTROWELNEXT:
2664 case mfTROWELSPECIALITEM:
2665 case mfSLASHPOT:
2666 case mfLIFTPOT:
2667 case mfLIFTORSLASH:
2668 case mfLIFTROCK:
2669 case mfLIFTROCKHEAVY:
2670 case mfDROPITEM:
2671 case mfSPECIALITEM:
2672 case mfDROPKEY:
2673 case mfDROPLKEY:
2674 case mfDROPCOMPASS:
2675 case mfDROPMAP:
2676 case mfDROPBOSSKEY:
2677 case mfSPAWNNPC:
2678 case mfSWITCHHOOK:
2679 case mfSIDEVIEWLADDER:
2680 case mfSIDEVIEWPLATFORM:
2681 case mfNOENEMYSPAWN:
2682 case mfENEMYALL:
2683 case mfNOMIRROR:
2684 case mfUNSAFEGROUND:
2685 case mf168:
2686 case mf169:
2687 case mf170:
2688 case mf171:
2689 case mf172:
2690 case mf173:
2691 case mf174:
2692 case mf175:
2693 case mf176:
2694 case mf177:
2695 case mf178:
2696 case mf179:
2697 case mf180:
2698 case mf181:
2699 case mf182:
2700 case mf183:
2701 case mf184:
2702 case mf185:
2703 case mf186:
2704 case mf187:
2705 case mf188:
2706 case mf189:
2707 case mf190:
2708 case mf191:
2709 case mf192:
2710 case mf193:
2711 case mf194:
2712 case mf195:
2713 case mf196:
2714 case mf197:
2715 case mf198:
2716 case mf199:
2717 case mf200:
2718 case mf201:
2719 case mf202:
2720 case mf203:
2721 case mf204:
2722 case mf205:
2723 case mf206:
2724 case mf207:
2725 case mf208:
2726 case mf209:
2727 case mf210:
2728 case mf211:
2729 case mf212:
2730 case mf213:
2731 case mf214:
2732 case mf215:
2733 case mf216:
2734 case mf217:
2735 case mf218:
2736 case mf219:
2737 case mf220:
2738 case mf221:
2739 case mf222:
2740 case mf223:
2741 case mf224:
2742 case mf225:
2743 case mf226:
2744 case mf227:
2745 case mf228:
2746 case mf229:
2747 case mf230:
2748 case mf231:
2749 case mf232:
2750 case mf233:
2751 case mf234:
2752 case mf235:
2753 case mf236:
2754 case mf237:
2755 case mf238:
2756 case mf239:
2757 case mf240:
2758 case mf241:
2759 case mf242:
2760 case mf243:
2761 case mf244:
2762 case mf245:
2763 case mf246:
2764 case mf247:
2765 case mf248:
2766 case mf249:
2767 case mf250:
2768 case mf251:
2769 case mf252:
2770 case mf253:
2771 case mf254:
2772 case mfEXTENDED:
2773 5706470 break;
2774
2775 case mfPUSHUD:
2776 case mfPUSHLR:
2777 case mfPUSH4:
2778 case mfPUSHU:
2779 case mfPUSHD:
2780 case mfPUSHL:
2781 case mfPUSHR:
2782 case mfPUSHUDNS:
2783 case mfPUSHLRNS:
2784 case mfPUSH4NS:
2785 case mfPUSHUNS:
2786 case mfPUSHDNS:
2787 case mfPUSHLNS:
2788 case mfPUSHRNS:
2789 case mfPUSHUDINS:
2790 case mfPUSHLRINS:
2791 case mfPUSH4INS:
2792 case mfPUSHUINS:
2793 case mfPUSHDINS:
2794 case mfPUSHLINS:
2795 case mfPUSHRINS:
2796
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2797
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2798 {
2799 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2800 }
2801
2802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2803
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2804 {
2805
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2806 {
2807
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2808 {
2809 case cPUSH_HEAVY:
2810 case cPUSH_HW:
2811 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2812 72 tempitemx=x, tempitemy=y;
2813
2814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2815 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2816
2817 72 break;
2818
2819 case cPUSH_HEAVY2:
2820 case cPUSH_HW2:
2821 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2822 63 tempitemx=x, tempitemy=y;
2823
2824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2825 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2826
2827 63 break;
2828 }
2829 1032 }
2830 2438 }
2831
2832 3148 break;
2833
2834 case mfWHISTLE:
2835
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2836 {
2837 tempitem=getItemID(itemsbuf,itype_whistle,1);
2838
2839 if(tempitem<0) break;
2840
2841 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2842 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2843 {
2844 tempitemx=x;
2845 tempitemy=y;
2846 }
2847
2848 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2849 }
2850
2851 2418 break;
2852
2853 //Why is this here?
2854 case mfFAIRY:
2855 case mfMAGICFAIRY:
2856 case mfALLFAIRY:
2857 if(hints)
2858 {
2859 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2860
2861 if(tempitem < 0) break;
2862
2863 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2864 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2865 {
2866 tempitemx=x;
2867 tempitemy=y;
2868 }
2869
2870 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2871 }
2872
2873 break;
2874
2875 case mfANYFIRE:
2876
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2877 {
2878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2879 252 }
2880 else
2881 {
2882 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2883
2884
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2885
2886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2887
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2888 {
2889 189 tempitemx=x;
2890 189 tempitemy=y;
2891 189 }
2892
2893 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2894 }
2895
2896 504 break;
2897
2898 case mfSTRONGFIRE:
2899 if(!hints)
2900 {
2901 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2902 }
2903 else
2904 {
2905 tempitem=getItemID(itemsbuf,itype_candle,2);
2906
2907 if(tempitem<0) break;
2908
2909 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2910 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2911 {
2912 tempitemx=x;
2913 tempitemy=y;
2914 }
2915
2916 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2917 }
2918
2919 break;
2920
2921 case mfMAGICFIRE:
2922 if(!hints)
2923 {
2924 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2925 }
2926 else
2927 {
2928 tempitem=getItemID(itemsbuf,itype_wand,1);
2929
2930 if(tempitem<0) break;
2931
2932 tempweapon=wFire;
2933
2934 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2935 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2936 {
2937 tempitemx=x;
2938 tempitemy=y;
2939 }
2940 else
2941 {
2942 tempweaponx=x;
2943 tempweapony=y;
2944 }
2945
2946 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2947 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2948 }
2949
2950 break;
2951
2952 case mfDIVINEFIRE:
2953 if(!hints)
2954 {
2955 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2956 }
2957 else
2958 {
2959 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2960
2961 if(tempitem<0) break;
2962
2963 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2964 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2965 {
2966 tempitemx=x;
2967 tempitemy=y;
2968 }
2969
2970 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2971 }
2972
2973 break;
2974
2975 case mfARROW:
2976
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2977 {
2978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2979 732 }
2980 else
2981 {
2982 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2983
2984
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2985
2986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2987
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2988 {
2989 61 tempitemx=x;
2990 61 tempitemy=y;
2991 61 }
2992
2993 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2994 }
2995
2996 814 break;
2997
2998 case mfSARROW:
2999 if(!hints)
3000 {
3001 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3002 }
3003 else
3004 {
3005 tempitem=getItemID(itemsbuf,itype_arrow,2);
3006
3007 if(tempitem<0) break;
3008
3009 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3010 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3011 {
3012 tempitemx=x;
3013 tempitemy=y;
3014 }
3015
3016 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3017 }
3018
3019 break;
3020
3021 case mfGARROW:
3022 if(!hints)
3023 {
3024 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3025 }
3026 else
3027 {
3028 tempitem=getItemID(itemsbuf,itype_arrow,3);
3029
3030 if(tempitem<0) break;
3031
3032 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3033 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3034 {
3035 tempitemx=x;
3036 tempitemy=y;
3037 }
3038
3039 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3040 }
3041
3042 break;
3043
3044 case mfBOMB:
3045
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3046 {
3047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3048 16 }
3049 else
3050 {
3051 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3052 17 tempweapon = wLitBomb;
3053
3054 //if (tempitem<0) break;
3055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3056
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3057 {
3058 12 tempweaponx=x;
3059 12 tempweapony=y;
3060 12 }
3061
3062 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3063 }
3064
3065 33 break;
3066
3067 case mfSBOMB:
3068
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3069 {
3070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3071 48 }
3072 else
3073 {
3074 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3075 //if (tempitem<0) break;
3076 48 tempweapon = wLitSBomb;
3077
3078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3079
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3080 {
3081 36 tempweaponx=x;
3082 36 tempweapony=y;
3083 36 }
3084
3085 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3086 }
3087
3088 96 break;
3089
3090 case mfARMOS_SECRET:
3091
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3092 {
3093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3094 12 }
3095 24 break;
3096
3097 case mfBRANG:
3098
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3099 {
3100 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3101 }
3102 else
3103 {
3104 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3105
3106
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3107
3108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3109
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3110 {
3111 4 tempitemx=x;
3112 4 tempitemy=y;
3113 4 }
3114
3115 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3116 }
3117
3118 5 break;
3119
3120 case mfMBRANG:
3121 if(!hints)
3122 {
3123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3124 }
3125 else
3126 {
3127 tempitem=getItemID(itemsbuf,itype_brang,2);
3128
3129 if(tempitem<0) break;
3130
3131 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3132 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3133 {
3134 tempitemx=x;
3135 tempitemy=y;
3136 }
3137
3138 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3139 }
3140
3141 break;
3142
3143 case mfFBRANG:
3144 if(!hints)
3145 {
3146 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3147 }
3148 else
3149 {
3150 tempitem=getItemID(itemsbuf,itype_brang,3);
3151
3152 if(tempitem<0) break;
3153
3154 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3155 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3156 {
3157 tempitemx=x;
3158 tempitemy=y;
3159 }
3160
3161 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3162 }
3163
3164 break;
3165
3166 case mfWANDMAGIC:
3167 if(!hints)
3168 {
3169 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3170 }
3171 else
3172 {
3173 tempitem=getItemID(itemsbuf,itype_wand,1);
3174
3175 if(tempitem<0) break;
3176
3177 tempweapon=itemsbuf[tempitem].wpn3;
3178
3179 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3180 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3181 {
3182 tempitemx=x;
3183 tempitemy=y;
3184 }
3185 else
3186 {
3187 tempweaponx=x;
3188 tempweapony=y;
3189 --lens_hint_weapon[wMagic][4];
3190
3191 if(lens_hint_weapon[wMagic][4]<-8)
3192 {
3193 lens_hint_weapon[wMagic][4]=8;
3194 }
3195 }
3196
3197 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3198 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3199 }
3200
3201 break;
3202
3203 case mfREFMAGIC:
3204
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3205 {
3206 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3207 }
3208 else
3209 {
3210 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3211
3212
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3213
3214 16 tempweapon=ewMagic;
3215
3216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3217
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3218 {
3219 13 tempitemx=x;
3220 13 tempitemy=y;
3221 13 }
3222 else
3223 {
3224 3 tempweaponx=x;
3225 3 tempweapony=y;
3226
3227
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3228 {
3229 1 --lens_hint_weapon[ewMagic][4];
3230 1 }
3231 else
3232 {
3233 2 ++lens_hint_weapon[ewMagic][4];
3234 }
3235
3236
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3237 {
3238 lens_hint_weapon[ewMagic][2]=up;
3239 }
3240
3241
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3242 {
3243 2 lens_hint_weapon[ewMagic][2]=down;
3244 2 }
3245 }
3246
3247 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3248 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3249 }
3250
3251 16 break;
3252
3253 case mfREFFIREBALL:
3254
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3255 {
3256 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3257 }
3258 else
3259 {
3260 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3261
3262
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3263
3264 16 tempweapon=ewFireball;
3265
3266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3267
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3268 {
3269 12 tempitemx=x;
3270 12 tempitemy=y;
3271 12 tempweaponx=x;
3272 12 tempweapony=y;
3273 12 ++lens_hint_weapon[ewFireball][3];
3274
3275
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3276 {
3277 1 lens_hint_weapon[ewFireball][3]=-8;
3278 1 lens_hint_weapon[ewFireball][4]=8;
3279 1 }
3280
3281
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3282 {
3283 8 ++lens_hint_weapon[ewFireball][4];
3284 8 }
3285 else
3286 {
3287 4 --lens_hint_weapon[ewFireball][4];
3288 }
3289 12 }
3290
3291 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3292 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3293 }
3294
3295 16 break;
3296
3297 case mfSWORD:
3298
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3299 {
3300 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3301 }
3302 else
3303 {
3304 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3305
3306
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3307
3308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3309
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3310 {
3311 5 tempitemx=x;
3312 5 tempitemy=y;
3313 5 }
3314
3315 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3316 }
3317
3318 7 break;
3319
3320 case mfWSWORD:
3321 if(!hints)
3322 {
3323 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3324 }
3325 else
3326 {
3327 tempitem=getItemID(itemsbuf,itype_sword,2);
3328
3329 if(tempitem<0) break;
3330
3331 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3332 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3333 {
3334 tempitemx=x;
3335 tempitemy=y;
3336 }
3337
3338 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3339 }
3340
3341 break;
3342
3343 case mfMSWORD:
3344 if(!hints)
3345 {
3346 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3347 }
3348 else
3349 {
3350 tempitem=getItemID(itemsbuf,itype_sword,3);
3351
3352 if(tempitem<0) break;
3353
3354 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3355 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3356 {
3357 tempitemx=x;
3358 tempitemy=y;
3359 }
3360
3361 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3362 }
3363
3364 break;
3365
3366 case mfXSWORD:
3367 if(!hints)
3368 {
3369 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3370 }
3371 else
3372 {
3373 tempitem=getItemID(itemsbuf,itype_sword,4);
3374
3375 if(tempitem<0) break;
3376
3377 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3378 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3379 {
3380 tempitemx=x;
3381 tempitemy=y;
3382 }
3383
3384 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3385 }
3386
3387 break;
3388
3389 case mfSWORDBEAM:
3390
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3391 {
3392 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3393 }
3394 else
3395 {
3396 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3397
3398
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3399
3400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3401
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3402 {
3403 11 tempitemx=x;
3404 11 tempitemy=y;
3405 11 }
3406
3407 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3408 }
3409
3410 16 break;
3411
3412 case mfWSWORDBEAM:
3413 if(!hints)
3414 {
3415 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3416 }
3417 else
3418 {
3419 tempitem=getItemID(itemsbuf,itype_sword,2);
3420
3421 if(tempitem<0) break;
3422
3423 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3424 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3425 {
3426 tempitemx=x;
3427 tempitemy=y;
3428 }
3429
3430 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3431 }
3432
3433 break;
3434
3435 case mfMSWORDBEAM:
3436 if(!hints)
3437 {
3438 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3439 }
3440 else
3441 {
3442 tempitem=getItemID(itemsbuf,itype_sword,3);
3443
3444 if(tempitem<0) break;
3445
3446 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3447 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3448 {
3449 tempitemx=x;
3450 tempitemy=y;
3451 }
3452
3453 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3454 }
3455
3456 break;
3457
3458 case mfXSWORDBEAM:
3459 if(!hints)
3460 {
3461 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3462 }
3463 else
3464 {
3465 tempitem=getItemID(itemsbuf,itype_sword,4);
3466
3467 if(tempitem<0) break;
3468
3469 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3470 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3471 {
3472 tempitemx=x;
3473 tempitemy=y;
3474 }
3475
3476 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3477 }
3478
3479 break;
3480
3481 case mfHOOKSHOT:
3482
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3483 {
3484 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3485 }
3486 else
3487 {
3488 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3489
3490
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3491
3492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3493
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3494 {
3495 12 tempitemx=x;
3496 12 tempitemy=y;
3497 12 }
3498
3499 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3500 }
3501
3502 17 break;
3503
3504 case mfWAND:
3505
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3506 {
3507 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3508 }
3509 else
3510 {
3511 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3512
3513
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3514
3515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3516
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3517 {
3518 28 tempitemx=x;
3519 28 tempitemy=y;
3520 28 }
3521
3522 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3523 }
3524
3525 35 break;
3526
3527 case mfHAMMER:
3528
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3529 {
3530 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3531 }
3532 else
3533 {
3534 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3535
3536
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3537
3538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3539
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3540 {
3541 13 tempitemx=x;
3542 13 tempitemy=y;
3543 13 }
3544
3545 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3546 }
3547
3548 17 break;
3549
3550 case mfARMOS_ITEM:
3551 case mfDIVE_ITEM:
3552
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3553 {
3554 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3555 2064 }
3556 2064 break;
3557
3558 case 16:
3559 case 17:
3560 case 18:
3561 case 19:
3562 case 20:
3563 case 21:
3564 case 22:
3565 case 23:
3566 case 24:
3567 case 25:
3568 case 26:
3569 case 27:
3570 case 28:
3571 case 29:
3572 case 30:
3573 case 31:
3574
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3576 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3577
3578 3618 break;
3579 case mfSECRETSNEXT:
3580 if(!hints)
3581 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3582 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3583
3584 break;
3585
3586 case mfSTRIKE:
3587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3588 {
3589 906 goto special;
3590 }
3591 else
3592 {
3593 break;
3594 }
3595
3596 28640 default: goto special;
3597
3598 special:
3599
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3600 {
3601
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3602 {
3603 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3604 4913 }
3605 6549 }
3606
3607 29546 break;
3608 }
3609 5748864 }
3610 2874432 }
3611
3612
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3613 {
3614
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3615 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3616
3617
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3618 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3619
3620
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3621 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3622
3623
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3624 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3625
3626
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3627 {
3628 43 showbombeddoor(dest, 0);
3629 43 }
3630
3631
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3632 {
3633 39 showbombeddoor(dest, 1);
3634 39 }
3635
3636
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3637 {
3638 showbombeddoor(dest, 2);
3639 }
3640
3641
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3642 {
3643 37 showbombeddoor(dest, 3);
3644 37 }
3645 8166 }
3646
3647
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3648 {
3649
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3650 {
3651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3652 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3653 1123 }
3654 else
3655 {
3656
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3657 {
3658 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3659 48 int32_t tempitemx=-16;
3660 48 int32_t tempitemy=-16;
3661
3662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3663
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3664 {
3665 24 tempitemx=tmpscr->stairx;
3666 24 tempitemy=tmpscr->stairy+playing_field_offset;
3667 24 }
3668
3669 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3670 48 }
3671 }
3672 2034 }
3673 }
3674 16332 }
3675
3676 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3677
3678 7997 void draw_lens_over()
3679 {
3680 // Oh, what the heck.
3681 static BITMAP *lens_scr = NULL;
3682 static int32_t last_width = -1;
3683 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3684
3685 // Only redraw the circle if the size has changed
3686
2/2
✓ Branch 0 taken 7987 times.
✓ Branch 1 taken 10 times.
7997 if(width != last_width)
3687 {
3688
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(lens_scr == NULL)
3689 {
3690 10 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3691 10 }
3692
3693 10 clear_to_color(lens_scr, BLACK);
3694 10 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3695 10 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3696 10 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3697 10 last_width=width;
3698 10 }
3699
3700 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3701 7997 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3702 7997 }
3703
3704 //----------------------------------------------------------------
3705
3706 31111 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3707 {
3708 //recreating a big bitmap every frame is highly sluggish.
3709
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 31108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
31111 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3710 31111 clear_to_color(wavebuf, BLACK);
3711 31111 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3712
3713 int32_t ofs;
3714 // int32_t amplitude=8;
3715 // int32_t wavelength=4;
3716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31111 times.
31111 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3717
3/6
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3718 31111 int32_t amp2=168;
3719
2/4
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3720 31111 int32_t i=frame%amp2;
3721
3722
2/2
✓ Branch 0 taken 5226648 times.
✓ Branch 1 taken 31111 times.
5257759 for(int32_t j=0; j<168; j++)
3723 {
3724
3/4
✓ Branch 0 taken 2613324 times.
✓ Branch 1 taken 2613324 times.
✓ Branch 2 taken 2613324 times.
✗ Branch 3 not taken.
5226648 if(j&1 && interpol)
3725 {
3726 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3727 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3728 }
3729 else
3730 {
3731 5226648 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3732 }
3733
3734
1/2
✓ Branch 0 taken 5226648 times.
✗ Branch 1 not taken.
5226648 if(ofs)
3735 {
3736
2/2
✓ Branch 0 taken 1338021888 times.
✓ Branch 1 taken 5226648 times.
1343248536 for(int32_t k=0; k<256; k++)
3737 {
3738 1338021888 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3739 1338021888 }
3740 5226648 }
3741 5226648 }
3742 31111 }
3743
3744 4848 void draw_fuzzy(int32_t fuzz)
3745 // draws from right half of scrollbuf to framebuf
3746 {
3747 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3748 byte *start, *si, *di;
3749
3750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4848 times.
4848 if(fuzz<1)
3751 fuzz = 1;
3752
3753 4848 xstep = 128%fuzz;
3754
3755
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 3838 times.
4848 if(xstep > 0)
3756 3838 xstep = fuzz-xstep;
3757
3758 4848 ystep = 112%fuzz;
3759
3760
2/2
✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 3434 times.
4848 if(ystep > 0)
3761 3434 ystep = fuzz-ystep;
3762
3763 4848 firsty = 1;
3764
3765
2/2
✓ Branch 0 taken 4848 times.
✓ Branch 1 taken 174932 times.
179780 for(y=0; y<224;)
3766 {
3767 174932 start = &(scrollbuf->line[y][256]);
3768
3769
4/4
✓ Branch 0 taken 172508 times.
✓ Branch 1 taken 1088376 times.
✓ Branch 2 taken 1085952 times.
✓ Branch 3 taken 174932 times.
1260884 for(dy=0; dy<ystep && dy+y<224; dy++)
3770 {
3771 1085952 si = start;
3772 1085952 di = &(framebuf->line[y+dy][0]);
3773 1085952 i = xstep;
3774 1085952 firstx = 1;
3775
3776
2/2
✓ Branch 0 taken 278003712 times.
✓ Branch 1 taken 1085952 times.
279089664 for(dx=0; dx<256; dx++)
3777 {
3778 278003712 *(di++) = *si;
3779
3780
2/2
✓ Branch 0 taken 234248896 times.
✓ Branch 1 taken 43754816 times.
278003712 if(++i >= fuzz)
3781 {
3782
2/2
✓ Branch 0 taken 42668864 times.
✓ Branch 1 taken 1085952 times.
43754816 if(!firstx)
3783 42668864 si += fuzz;
3784 else
3785 {
3786 1085952 si += fuzz-xstep;
3787 1085952 firstx = 0;
3788 }
3789
3790 43754816 i = 0;
3791 43754816 }
3792 278003712 }
3793 1085952 }
3794
3795
2/2
✓ Branch 0 taken 170084 times.
✓ Branch 1 taken 4848 times.
174932 if(!firsty)
3796 170084 y += fuzz;
3797 else
3798 {
3799 4848 y += ystep;
3800 4848 ystep = fuzz;
3801 4848 firsty = 0;
3802 }
3803 }
3804 4848 }
3805
3806 9285528 void updatescr(bool allowwavy)
3807 {
3808
4/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 9285414 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 114 times.
✗ Branch 5 not taken.
9285528 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3809
4/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 9285414 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 114 times.
9285528 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3810
3811
2/2
✓ Branch 0 taken 9258763 times.
✓ Branch 1 taken 26765 times.
9285528 if(toogam)
3812 {
3813 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3814 26765 }
3815
3816
1/2
✓ Branch 0 taken 9285528 times.
✗ Branch 1 not taken.
9285528 if(Showpal)
3817 dump_pal(framebuf);
3818
3819
2/2
✓ Branch 0 taken 8984296 times.
✓ Branch 1 taken 301232 times.
9285528 if(!Playing)
3820 301232 black_opening_count=0;
3821
3822
2/2
✓ Branch 0 taken 9212400 times.
✓ Branch 1 taken 73128 times.
9285528 if(black_opening_count<0) //shape is opening up
3823 {
3824 73128 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3825
3826
2/4
✓ Branch 0 taken 73128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73128 times.
73128 if(Advance||(!Paused))
3827 {
3828 73128 ++black_opening_count;
3829 73128 }
3830 73128 }
3831
2/2
✓ Branch 0 taken 9186264 times.
✓ Branch 1 taken 26136 times.
9212400 else if(black_opening_count>0) //shape is closing
3832 {
3833 26136 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3834
3835
2/4
✓ Branch 0 taken 26136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26136 times.
26136 if(Advance||(!Paused))
3836 {
3837 26136 --black_opening_count;
3838 26136 }
3839 26136 }
3840
3841
3/4
✓ Branch 0 taken 9187768 times.
✓ Branch 1 taken 97760 times.
✓ Branch 2 taken 9187768 times.
✗ Branch 3 not taken.
9285528 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3842 {
3843 black_opening_shape = bosCIRCLE;
3844 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3845 refreshTints();
3846 refreshpal=true;
3847 }
3848
3849
2/2
✓ Branch 0 taken 9031331 times.
✓ Branch 1 taken 254197 times.
9285528 if(refreshpal)
3850 {
3851 254197 refreshpal=false;
3852 254197 RAMpal[253] = _RGB(0,0,0);
3853 254197 RAMpal[254] = _RGB(63,63,63);
3854 254197 hw_palette = &RAMpal;
3855 254197 update_hw_pal = true;
3856
3857 254197 create_rgb_table(&rgb_table, RAMpal, NULL);
3858 254197 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3859 254197 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3860
3861
2/2
✓ Branch 0 taken 65074432 times.
✓ Branch 1 taken 254197 times.
65328629 for(int32_t q=0; q<PAL_SIZE; q++)
3862 {
3863 65074432 trans_table2.data[0][q] = q;
3864 65074432 trans_table2.data[q][q] = q;
3865 65074432 }
3866 254197 }
3867
3868 9285528 bool clearwavy = (wavy <= 0);
3869
3870
2/2
✓ Branch 0 taken 7655 times.
✓ Branch 1 taken 9277873 times.
9285528 if(wavy <= 0)
3871 {
3872 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3873 9277873 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3874 9277873 }
3875
3876 9285528 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3877
3878
6/6
✓ Branch 0 taken 31361 times.
✓ Branch 1 taken 9254167 times.
✓ Branch 2 taken 31239 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31111 times.
9285528 if(wavy && Playing && allowwavy)
3879 {
3880 31111 draw_wavy(framebuf, wavybuf, wavy,false);
3881 31111 }
3882
3883
2/2
✓ Branch 0 taken 9277873 times.
✓ Branch 1 taken 7655 times.
9285528 if(clearwavy)
3884 9277873 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3885
2/4
✓ Branch 0 taken 7655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7655 times.
7655 else if(Playing && !Paused)
3886 7655 wavy--; // Wavy was set by a script. Decrement it.
3887
3888
5/6
✓ Branch 0 taken 8984296 times.
✓ Branch 1 taken 301232 times.
✓ Branch 2 taken 259415 times.
✓ Branch 3 taken 8724881 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 259415 times.
9285528 if(Playing && msgpos && !screenscrolling)
3889 {
3890
1/2
✓ Branch 0 taken 259415 times.
✗ Branch 1 not taken.
259415 if(!(msg_bg_display_buf->clip))
3891 259415 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3892
1/2
✓ Branch 0 taken 259415 times.
✗ Branch 1 not taken.
259415 if(!(msg_portrait_display_buf->clip))
3893 259415 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3894
1/2
✓ Branch 0 taken 259415 times.
✗ Branch 1 not taken.
259415 if(!(msg_txt_display_buf->clip))
3895 259415 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3896 259415 }
3897
3898 /*
3899 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3900 {
3901 BITMAP* subBmp = 0;
3902 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3903 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3904 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3905 destroy_bitmap(subBmp);
3906 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3907 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3908 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3909 }
3910 */
3911
3912
2/2
✓ Branch 0 taken 9244471 times.
✓ Branch 1 taken 41057 times.
9285528 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3913
3914
2/2
✓ Branch 0 taken 9249096 times.
✓ Branch 1 taken 36432 times.
9285528 if(nosubscr)
3915 {
3916 36432 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3917 36432 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3918 36432 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3919 36432 }
3920
3921 //TODO: Optimize blit 'overcalls' -Gleeok
3922
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9249096 times.
9285528 BITMAP *source = nosubscr ? panorama : wavybuf;
3923 9285528 blit(source,framebuf,0,0,0,0,256,224);
3924
3925 9285528 update_hw_screen();
3926 9285528 }
3927
3928 //----------------------------------------------------------------
3929
3930 static PALETTE syspal;
3931 int32_t onGUISnapshot()
3932 {
3933 char buf[200];
3934 int32_t num=0;
3935 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3936 do
3937 {
3938 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3939 }
3940 while(num<99999 && exists(buf));
3941
3942 BITMAP *b = create_bitmap_ex(8,resx,resy);
3943
3944 if(b)
3945 {
3946 blit(screen,b,0,0,0,0,resx,resy);
3947 save_bitmap(buf,screen,RAMpal);
3948 destroy_bitmap(b);
3949 }
3950
3951 return D_O_K;
3952 }
3953
3954 int32_t onNonGUISnapshot()
3955 {
3956 PALETTE temppal;
3957 get_palette(temppal);
3958 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3959
3960 char buf[200];
3961 int32_t num=0;
3962
3963 do
3964 {
3965 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3966 }
3967 while(num<99999 && exists(buf));
3968
3969 if (tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3970 {
3971 BITMAP *b = create_bitmap_ex(8,256,168);
3972 clear_to_color(b,0);
3973 blit(framebuf,b,0,passive_subscreen_height/2,0,0,256,168);
3974 save_bitmap(buf,b,realpal?temppal:RAMpal);
3975 destroy_bitmap(b);
3976 }
3977 else
3978 {
3979 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3980 }
3981
3982 return D_O_K;
3983 }
3984
3985 int32_t onSnapshot()
3986 {
3987 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3988 {
3989 onGUISnapshot();
3990 }
3991 else
3992 {
3993 onNonGUISnapshot();
3994 }
3995
3996 return D_O_K;
3997 }
3998
3999 int32_t onSaveMapPic()
4000 {
4001 int32_t mapres2 = 0;
4002 char buf[200];
4003 int32_t num=0;
4004 mapscr tmpscr_b[2];
4005 mapscr tmpscr_c[6];
4006 BITMAP* _screen_draw_buffer = NULL;
4007 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4008 set_clip_state(_screen_draw_buffer,1);
4009
4010 for(int32_t i=0; i<6; ++i)
4011 {
4012 tmpscr_c[i] = tmpscr2[i];
4013 tmpscr2[i].zero_memory();
4014
4015 if(i>=2)
4016 {
4017 continue;
4018 }
4019
4020 tmpscr_b[i] = tmpscr[i];
4021 tmpscr[i].zero_memory();
4022 }
4023
4024 do
4025 {
4026 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4027 }
4028 while(num<99999 && exists(buf));
4029
4030 BITMAP* mappic = NULL;
4031
4032
4033 bool done=false, redraw=true;
4034
4035 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4036
4037 if(!mappic)
4038 {
4039 enter_sys_pal();
4040 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4041 exit_sys_pal();
4042 return D_O_K;;
4043 }
4044
4045 // draw the map
4046 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4047
4048 for(int32_t y=0; y<8; y++)
4049 {
4050 for(int32_t x=0; x<16; x++)
4051 {
4052 if(!displayOnMap(x, y))
4053 {
4054 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4055 }
4056 else
4057 {
4058 int32_t s = (y<<4) + x;
4059 loadscr2(1,s,-1);
4060
4061 for(int32_t i=0; i<6; i++)
4062 {
4063 if(tmpscr[1].layermap[i]<=0)
4064 continue;
4065
4066 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4067 }
4068
4069 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4070
4071 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4072
4073 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4074 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4075
4076 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4077
4078 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4079 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4080 {
4081 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4082 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4083 {
4084 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4085 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4086 }
4087 }
4088 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4089
4090 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4091
4092 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4093 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4094 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4095 {
4096 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4097 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4098 }
4099 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4100 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4101
4102 }
4103
4104 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4105 }
4106 }
4107
4108 for(int32_t i=0; i<6; ++i)
4109 {
4110 tmpscr2[i]=tmpscr_c[i];
4111
4112 if(i>=2)
4113 {
4114 continue;
4115 }
4116
4117 tmpscr[i]=tmpscr_b[i];
4118 }
4119
4120 save_bitmap(buf,mappic,RAMpal);
4121 destroy_bitmap(mappic);
4122 destroy_bitmap(_screen_draw_buffer);
4123 return D_O_K;
4124 }
4125
4126 14 void f_Quit(int32_t type)
4127 {
4128
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4129 return;
4130
4131 14 bool from_menu = is_sys_pal;
4132
4133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4134 {
4135 14 music_pause();
4136 14 pause_all_sfx();
4137 14 sys_mouse();
4138 14 }
4139 14 enter_sys_pal();
4140 14 clear_keybuf();
4141
4142
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (replay_version_check(0, 10))
4143 13 replay_poll();
4144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4145 14 replay_peek_quit();
4146
4147
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4148 switch(type)
4149 {
4150 case qQUIT:
4151 onQuit();
4152 break;
4153
4154 case qRESET:
4155 onReset();
4156 break;
4157
4158 case qEXIT:
4159 onExit();
4160 break;
4161 }
4162
4163
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4164 {
4165 14 kill_sfx();
4166 14 music_stop();
4167 14 exit_sys_pal();
4168 14 update_hw_screen();
4169 14 }
4170 else
4171 {
4172 exit_sys_pal();
4173 if(!from_menu)
4174 {
4175 music_resume();
4176 resume_all_sfx();
4177 }
4178 }
4179
4180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4181 14 game_mouse();
4182 14 eat_buttons();
4183
4184 14 zc_readrawkey(KEY_ESC);
4185
4186 14 zc_readrawkey(KEY_ENTER);
4187 14 }
4188
4189 //----------------------------------------------------------------
4190
4191 int32_t onNoWalls()
4192 {
4193 cheats_enqueue(Cheat::Walls);
4194 return D_O_K;
4195 }
4196
4197 int32_t onIgnoreSideview()
4198 {
4199 cheats_enqueue(Cheat::IgnoreSideView);
4200 return D_O_K;
4201 }
4202
4203 9285403 int32_t input_idle(bool checkmouse)
4204 {
4205 static int32_t mx, my, mz, mb;
4206
4207
4/6
✓ Branch 0 taken 9285403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461236 times.
✓ Branch 3 taken 6824167 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2461236 times.
11746639 if(keypressed() || zc_key_pressed() ||
4208
4/8
✓ Branch 0 taken 2461236 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461236 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2461236 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2461236 times.
✗ Branch 7 not taken.
2461236 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4209 {
4210 6824167 idle_count = 0;
4211
4212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6824167 times.
6824167 if(active_count < MAX_ACTIVE)
4213 {
4214 6824167 ++active_count;
4215 6824167 }
4216 6824167 }
4217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2461236 times.
2461236 else if(idle_count < MAX_IDLE)
4218 {
4219 2461236 ++idle_count;
4220 2461236 active_count = 0;
4221 2461236 }
4222
4223 9285403 mx = mouse_x;
4224 9285403 my = mouse_y;
4225 9285403 mz = mouse_z;
4226 9285403 mb = mouse_b;
4227
4228 9285403 return idle_count;
4229 }
4230
4231 int32_t onGoFast()
4232 {
4233 cheats_enqueue(Cheat::Fast);
4234 return D_O_K;
4235 }
4236
4237 int32_t onKillCheat()
4238 {
4239 cheats_enqueue(Cheat::Kill);
4240 return D_O_K;
4241 }
4242
4243 int32_t onSecretsCheat()
4244 {
4245 cheats_enqueue(Cheat::TrigSecrets);
4246 return D_O_K;
4247 }
4248 int32_t onSecretsCheatPerm()
4249 {
4250 cheats_enqueue(Cheat::TrigSecretsPerm);
4251 return D_O_K;
4252 }
4253
4254 int32_t onShowLayer0()
4255 {
4256 show_layer_0 = !show_layer_0;
4257 return D_O_K;
4258 }
4259 int32_t onShowLayer1()
4260 {
4261 show_layer_1 = !show_layer_1;
4262 return D_O_K;
4263 }
4264 int32_t onShowLayer2()
4265 {
4266 show_layer_2 = !show_layer_2;
4267 return D_O_K;
4268 }
4269 int32_t onShowLayer3()
4270 {
4271 show_layer_3 = !show_layer_3;
4272 return D_O_K;
4273 }
4274 int32_t onShowLayer4()
4275 {
4276 show_layer_4 = !show_layer_4;
4277 return D_O_K;
4278 }
4279 int32_t onShowLayer5()
4280 {
4281 show_layer_5 = !show_layer_5;
4282 return D_O_K;
4283 }
4284 int32_t onShowLayer6()
4285 {
4286 show_layer_6 = !show_layer_6;
4287 return D_O_K;
4288 }
4289 int32_t onShowLayerO()
4290 {
4291 show_layer_over=!show_layer_over;
4292 return D_O_K;
4293 }
4294 int32_t onShowLayerP()
4295 {
4296 show_layer_push=!show_layer_push;
4297 return D_O_K;
4298 }
4299 int32_t onShowLayerS()
4300 {
4301 show_sprites=!show_sprites;
4302 return D_O_K;
4303 }
4304 int32_t onShowLayerF()
4305 {
4306 show_ffcs=!show_ffcs;
4307 return D_O_K;
4308 }
4309 int32_t onShowLayerW()
4310 {
4311 show_walkflags=!show_walkflags;
4312 if(show_walkflags)
4313 show_effectflags = false;
4314 return D_O_K;
4315 }
4316 int32_t onShowLayerE()
4317 {
4318 show_effectflags=!show_effectflags;
4319 if(show_effectflags)
4320 show_walkflags = false;
4321 return D_O_K;
4322 }
4323 int32_t onShowFFScripts()
4324 {
4325 show_ff_scripts=!show_ff_scripts;
4326 return D_O_K;
4327 }
4328 int32_t onShowHitboxes()
4329 {
4330 show_hitboxes=!show_hitboxes;
4331 return D_O_K;
4332 }
4333 int32_t onShowInfoOpacity()
4334 {
4335 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4336 zc_set_config("zc","debug_info_opacity",info_opacity);
4337 return D_O_K;
4338 }
4339
4340 int32_t onLightSwitch()
4341 {
4342 cheats_enqueue(Cheat::Light);
4343 return D_O_K;
4344 }
4345
4346 int32_t onGoTo();
4347 int32_t onGoToComplete();
4348
4349 9285403 bool handle_close_btn_quit()
4350 {
4351
1/2
✓ Branch 0 taken 9285403 times.
✗ Branch 1 not taken.
9285403 if(close_button_quit)
4352 {
4353 close_button_quit=false;
4354 f_Quit(qEXIT);
4355 }
4356 9285403 return (exiting_program = Quit==qEXIT);
4357 }
4358
4359 9285403 void syskeys()
4360 {
4361 9285403 update_system_keys();
4362
4363 int32_t oldtitle_version;
4364
4365 9285403 poll_joystick();
4366
4367 9285403 handle_close_btn_quit();
4368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285403 times.
9285403 if(Quit == qEXIT) return;
4369
4370
2/10
✓ Branch 0 taken 9285403 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9285403 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9285403 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4371 {
4372 System();
4373 }
4374
4375 9285403 mouse_down=gui_mouse_b();
4376
4377
1/2
✓ Branch 0 taken 9285403 times.
✗ Branch 1 not taken.
9285403 if(zc_read_system_key(KEY_F1))
4378 {
4379 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4380 {
4381 halt=!halt;
4382 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4383 }
4384 else
4385 {
4386 Throttlefps=!Throttlefps;
4387 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4388 }
4389 }
4390
4391 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4392 /*
4393 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4394 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4395 */
4396
4397
1/2
✓ Branch 0 taken 9285403 times.
✗ Branch 1 not taken.
9285403 if(zc_read_system_key(KEY_F2))
4398 {
4399 ShowFPS=!ShowFPS;
4400 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4401 }
4402
4403
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9285403 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9285403 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4404
4405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9285403 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9285403 if(zc_read_system_key(KEY_F4) && Playing)
4406 {
4407 Paused=true;
4408 Advance=true;
4409 }
4410
4411
1/2
✓ Branch 0 taken 9285403 times.
✗ Branch 1 not taken.
9285403 if(zc_read_system_key(KEY_F6)) onTryQuit();
4412
4413 #ifndef ALLEGRO_MACOSX
4414
1/2
✓ Branch 0 taken 9285403 times.
✗ Branch 1 not taken.
9285403 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4415
4416
1/2
✓ Branch 0 taken 9285403 times.
✗ Branch 1 not taken.
9285403 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4417 #else
4418 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4419
4420 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4421 #endif
4422
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9285403 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9285403 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4423
4424
1/2
✓ Branch 0 taken 9285403 times.
✗ Branch 1 not taken.
9285403 if (zc_read_system_key(KEY_F12))
4425 {
4426 onSnapshot();
4427 }
4428
4429
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9285403 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9285403 if(debug_enabled && zc_read_system_key(KEY_TAB))
4430 set_debug(!get_debug());
4431
4432
1/2
✓ Branch 0 taken 9285403 times.
✗ Branch 1 not taken.
9285403 if(CheatModifierKeys())
4433 {
4434 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4435 {
4436 if(!bindable_cheat(c))
4437 continue;
4438 if(get_debug() || cheat >= cheat_lvl(c))
4439 {
4440 if(checkcheat(c))
4441 cheats_hit_bind(c);
4442 }
4443 }
4444 }
4445
4446
1/2
✓ Branch 0 taken 9285403 times.
✗ Branch 1 not taken.
9285403 if(volkeys)
4447 {
4448 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4449
4450 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4451
4452 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4453
4454 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4455 }
4456
4457
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9285403 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9285403 if(!get_debug() || !SystemKeys || replay_is_replaying())
4458 9285403 goto bottom;
4459
4460 if(zc_readkey(KEY_D))
4461 {
4462 details = !details;
4463 rectfill(screen,0,0,319,7,BLACK);
4464 rectfill(screen,0,8,31,239,BLACK);
4465 rectfill(screen,288,8,319,239,BLACK);
4466 rectfill(screen,32,232,287,239,BLACK);
4467 }
4468
4469 if(zc_readkey(KEY_P)) Paused=!Paused;
4470
4471 //if(zc_readkey(KEY_P)) centerHero();
4472 if(zc_readkey(KEY_A))
4473 {
4474 Paused=true;
4475 Advance=true;
4476 }
4477
4478 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4479 #ifndef ALLEGRO_MACOSX
4480 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4481
4482 if(zc_readkey(KEY_F7))
4483 {
4484 Matrix(ss_speed, ss_density, 0);
4485 game_pal();
4486 }
4487 #else
4488 // The reason these are different on Mac in the first place is that
4489 // the OS doesn't let us use F9 and F10...
4490 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4491
4492 if(zc_readkey(KEY_F9))
4493 {
4494 Matrix(ss_speed, ss_density, 0);
4495 game_pal();
4496 }
4497 #endif
4498 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4499 {
4500 //change containers
4501 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4502 {
4503 //magic containers
4504 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4505 {
4506 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4507 }
4508 else
4509 {
4510 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4511 }
4512 }
4513 else
4514 {
4515 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4516 {
4517 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4518 }
4519 else
4520 {
4521 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4522 }
4523 }
4524 }
4525
4526 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4527 {
4528 //change containers
4529 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4530 {
4531 //magic containers
4532 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4533 {
4534 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4535 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4536 //heart containers
4537 }
4538 else
4539 {
4540 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4541 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4542 }
4543 }
4544 else
4545 {
4546 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4547 {
4548 game->set_magic(zc_max(game->get_magic()-1,0));
4549 }
4550 else
4551 {
4552 game->set_life(zc_max(game->get_life()-1,0));
4553 }
4554 }
4555 }
4556
4557 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4558
4559 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4560
4561 verifyBothWeapons();
4562
4563 bottom:
4564
4565
1/2
✓ Branch 0 taken 9285403 times.
✗ Branch 1 not taken.
9285403 if(input_idle(true) > after_time())
4566 {
4567 Matrix(ss_speed, ss_density, 0);
4568 game_pal();
4569 }
4570 9285403 }
4571
4572 705772 void checkQuitKeys()
4573 {
4574 #ifndef ALLEGRO_MACOSX
4575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 705772 times.
705772 if(key[KEY_F9]) f_Quit(qRESET);
4576
4577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 705772 times.
705772 if(key[KEY_F10]) f_Quit(qEXIT);
4578 #else
4579 if(key[KEY_F7]) f_Quit(qRESET);
4580
4581 if(key[KEY_F8]) f_Quit(qEXIT);
4582 #endif
4583 705772 }
4584
4585 9285403 bool CheatModifierKeys()
4586 {
4587 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4588 // to trigger cheats.
4589
1/2
✓ Branch 0 taken 9285403 times.
✗ Branch 1 not taken.
9285403 if (replay_is_replaying())
4590 9285403 return false;
4591
4592 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4593 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4594 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4595 {
4596 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4597 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4598 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4599 {
4600 return true;
4601 }
4602 }
4603 return false;
4604 9285403 }
4605
4606 //99:05:54, for some reason?
4607 #define OLDMAXTIME 21405240
4608 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4609 #define MAXTIME 1944000000
4610
4611 9285528 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4612 {
4613
1/2
✓ Branch 0 taken 9285528 times.
✗ Branch 1 not taken.
9285528 if(zcmusic!=NULL)
4614 {
4615 zcmusic_poll();
4616 }
4617 9285528 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4618
4619 9285528 updatescr(allowwavy);
4620
4621 9285528 Advance=false;
4622
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9285528 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9285528 times.
9285528 while(Paused && !Advance && !Quit)
4623 {
4624 // have to call this, otherwise we'll get an infinite loop
4625 syskeys();
4626 if(allowF6Script)
4627 {
4628 FFCore.runF6Engine();
4629 }
4630 throttleFPS();
4631
4632 #ifdef _WIN32
4633
4634 if(use_dwm_flush)
4635 {
4636 do_DwmFlush();
4637 }
4638
4639 #endif
4640
4641 // to keep music playing
4642 if(zcmusic!=NULL)
4643 {
4644 zcmusic_poll();
4645 }
4646
4647 update_hw_screen();
4648 }
4649
4650
2/2
✓ Branch 0 taken 9285417 times.
✓ Branch 1 taken 111 times.
9285528 if(Quit)
4651 111 return;
4652
4653
3/4
✓ Branch 0 taken 8984288 times.
✓ Branch 1 taken 301129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8984288 times.
9285417 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4654 8984288 game->change_time(1);
4655
4656 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4657
4658 9285417 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4659
2/2
✓ Branch 0 taken 19895 times.
✓ Branch 1 taken 9265522 times.
9285417 if (replay_version_check(0, 16))
4660 9265522 should_reset_down_state = replay_version_check(11, 16);
4661
2/2
✓ Branch 0 taken 6948405 times.
✓ Branch 1 taken 2337012 times.
9285417 if (should_reset_down_state)
4662 {
4663
2/2
✓ Branch 0 taken 42066216 times.
✓ Branch 1 taken 2337012 times.
44403228 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4664 42066216 down_control_states[i] = raw_control_state[i];
4665 2337012 }
4666
4667
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9285403 times.
9285417 if (replay_is_active())
4668 {
4669
2/2
✓ Branch 0 taken 1270449 times.
✓ Branch 1 taken 8014954 times.
9285403 if (replay_version_check(3))
4670 8014954 replay_poll();
4671
4672
4/4
✓ Branch 0 taken 6944823 times.
✓ Branch 1 taken 2340580 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 6844288 times.
9285403 if (replay_version_check(11) || replay_version_check(6, 8))
4673 2441115 replay_peek_input();
4674 9285403 }
4675
4676 9285417 load_control_called_this_frame = false;
4677
4678 9285417 poll_keyboard();
4679 9285417 update_keys();
4680
4681 9285417 ++frame;
4682
4683
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9285403 times.
9285417 if (replay_is_replaying())
4684 9285403 replay_do_cheats();
4685 9285417 syskeys();
4686
4687 // The mouse variables can change from the mouse thread at anytime during a frame,
4688 // so save the result at the start so that replaying is consistent.
4689 9285417 script_mouse_x = gui_mouse_x();
4690 9285417 script_mouse_y = gui_mouse_y();
4691 9285417 script_mouse_z = mouse_z;
4692 9285417 script_mouse_b = mouse_b;
4693
4694 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4695 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4696 // approach here means it doesn't matter which call adds the cheat.
4697 9285417 cheats_execute_queued();
4698
4699
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9285403 times.
9285417 if (replay_is_replaying())
4700 9285403 replay_peek_quit();
4701
2/2
✓ Branch 0 taken 9285403 times.
✓ Branch 1 taken 14 times.
9285417 if (GameFlags & GAMEFLAG_TRYQUIT)
4702 14 replay_step_quit(0);
4703
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 9282483 times.
9285417 if(allowF6Script)
4704 9282483 FFCore.runF6Engine();
4705
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 9285119 times.
9285417 if (Quit)
4706 298 replay_step_quit(Quit);
4707 // Someday... maybe install a Turbo button here?
4708 9285417 throttleFPS();
4709
4710 #ifdef _WIN32
4711
4712 if(use_dwm_flush)
4713 {
4714 do_DwmFlush();
4715 }
4716
4717 #endif
4718
4719 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4720
2/2
✓ Branch 0 taken 68758 times.
✓ Branch 1 taken 9216659 times.
9285417 if(sfxcleanup)
4721 9216659 sfx_cleanup();
4722
4723 9285417 jit_poll();
4724
4725 #ifdef __EMSCRIPTEN__
4726 // Yield the main thread back to the browser occasionally.
4727 if (is_headless())
4728 {
4729 static int rate = 10000;
4730 static int force_yield = rate;
4731 if (force_yield++ >= rate)
4732 {
4733 force_yield = 0;
4734 emscripten_sleep(0);
4735 }
4736 }
4737 #endif
4738
4739
4/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 9285303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 114 times.
✗ Branch 5 not taken.
9285417 static bool test_mode_auto_restart = zc_get_config("zeldadx", "test_mode_auto_restart", false);
4740
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9285417 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9285417 if (zqtesting_mode && test_mode_auto_restart)
4741 {
4742 static auto last_write_time = fs::last_write_time(qstpath);
4743 static auto last_check = std::chrono::system_clock::now();
4744
4745 if (std::chrono::system_clock::now() - last_check > 200ms)
4746 {
4747 last_check = std::chrono::system_clock::now();
4748 auto write_time = fs::last_write_time(qstpath);
4749 if (last_write_time != write_time)
4750 {
4751 last_write_time = write_time;
4752 disableClickToFreeze = false;
4753 Quit = qRESET;
4754 replay_quit();
4755 }
4756 }
4757 }
4758 9285528 }
4759
4760 101 void zapout()
4761 {
4762 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4763 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4764
4765 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4766 101 script_drawing_commands.Clear();
4767
4768 // zap out
4769
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=1; i<=24; i++)
4770 {
4771 2424 draw_fuzzy(i);
4772 2424 advanceframe(true);
4773
4774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4775 {
4776 break;
4777 }
4778 2424 }
4779 101 }
4780
4781 101 void zapin()
4782 {
4783 101 FFCore.warpScriptCheck();
4784 101 draw_screen(tmpscr);
4785 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4786 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4787 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4788
4789 // zap out
4790 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4791
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=24; i>=1; i--)
4792 {
4793 2424 draw_fuzzy(i);
4794 2424 advanceframe(true);
4795
4796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4797 {
4798 break;
4799 }
4800 2424 }
4801 101 }
4802
4803
4804 65 void wavyout(bool showhero)
4805 {
4806 65 draw_screen(tmpscr, showhero);
4807 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4808
4809 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4810 65 clear_to_color(wavebuf,0);
4811 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4812
4813 static PALETTE wavepal;
4814
4815 int32_t ofs;
4816 65 int32_t amplitude=8;
4817
4818 65 int32_t wavelength=4;
4819 65 double palpos=0, palstep=4, palstop=126;
4820
4821 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4822
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4823 {
4824
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4825 {
4826 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4827 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4828 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4829 698880 }
4830
4831 2730 palpos+=palstep;
4832
4833
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4834 {
4835 2730 hw_palette = &wavepal;
4836 2730 update_hw_pal = true;
4837 2730 }
4838 else
4839 {
4840 hw_palette = &RAMpal;
4841 update_hw_pal = true;
4842 }
4843
4844
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4845 {
4846
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4847 {
4848 117411840 ofs=0;
4849
4850
4/4
✓ Branch 0 taken 57308160 times.
✓ Branch 1 taken 60103680 times.
✓ Branch 2 taken 28654080 times.
✓ Branch 3 taken 28654080 times.
117411840 if((j<i)&&(j&1))
4851 {
4852 28654080 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4853 28654080 }
4854
4855 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4856 117411840 }
4857 458640 }
4858
4859 2730 advanceframe(true);
4860
4861 // animate_combos();
4862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4863 break;
4864 2730 }
4865
4866 65 destroy_bitmap(wavebuf);
4867 65 }
4868
4869 65 void wavyin()
4870 {
4871 65 draw_screen(tmpscr);
4872 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4873
4874 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4875 65 clear_to_color(wavebuf,0);
4876 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4877
4878 static PALETTE wavepal;
4879
4880 //Breaks dark rooms.
4881 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4882 /*
4883 loadfullpal();
4884 loadlvlpal(DMaps[currdmap].color);
4885 ringcolor(false);
4886 */
4887 65 refreshpal=false;
4888 int32_t ofs;
4889 65 int32_t amplitude=8;
4890 65 int32_t wavelength=4;
4891 65 double palpos=168, palstep=4, palstop=126;
4892
4893 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4894
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4895 {
4896
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4897 {
4898 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4899 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4900 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4901 698880 }
4902
4903 2730 palpos-=palstep;
4904
4905
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4906 {
4907 2730 hw_palette = &wavepal;
4908 2730 update_hw_pal = true;
4909 2730 }
4910 else
4911 {
4912 hw_palette = &RAMpal;
4913 update_hw_pal = true;
4914 }
4915
4916
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4917 {
4918
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4919 {
4920 117411840 ofs=0;
4921
4922
4/4
✓ Branch 0 taken 59404800 times.
✓ Branch 1 taken 58007040 times.
✓ Branch 2 taken 30051840 times.
✓ Branch 3 taken 29352960 times.
117411840 if((j<(167-i))&&(j&1))
4923 {
4924 29352960 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4925 29352960 }
4926
4927 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4928 117411840 }
4929 458640 }
4930
4931 2730 advanceframe(true);
4932 // animate_combos();
4933
4934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4935 break;
4936 2730 }
4937
4938 65 destroy_bitmap(wavebuf);
4939 65 }
4940
4941 2168 void blackscr(int32_t fcnt,bool showsubscr)
4942 {
4943 2168 reset_pal_cycling();
4944 2168 script_drawing_commands.Clear();
4945
4946 2168 FFCore.warpScriptCheck();
4947 2168 bool showtime = game->should_show_time();
4948
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 64970 times.
67138 while(fcnt>0)
4949 {
4950 64970 clear_bitmap(framebuf);
4951
4952
2/2
✓ Branch 0 taken 25080 times.
✓ Branch 1 taken 39890 times.
64970 if(showsubscr)
4953 {
4954 39890 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4955
3/4
✓ Branch 0 taken 39890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 39140 times.
39890 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4956 {
4957 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4958 750 }
4959 39890 }
4960
4961 64970 advanceframe(true);
4962
4963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64970 times.
64970 if(Quit)
4964 break;
4965
4966 64970 --fcnt;
4967 }
4968 2168 }
4969
4970 1009 void openscreen(int32_t shape)
4971 {
4972 1009 reset_pal_cycling();
4973 1009 black_opening_count=0;
4974
4975
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 909 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
1009 if(COOLSCROLL || shape>-1)
4976 {
4977 909 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4978 909 return;
4979 }
4980 else
4981 {
4982 100 Hero.setDontDraw(true);
4983 100 show_subscreen_dmap_dots=false;
4984 100 show_subscreen_numbers=false;
4985 // show_subscreen_items=false;
4986 100 show_subscreen_life=false;
4987 }
4988
4989 100 int32_t x=128;
4990
4991 100 FFCore.warpScriptCheck();
4992
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8000 times.
8100 for(int32_t i=0; i<80; i++)
4993 {
4994 8000 draw_screen(tmpscr);
4995 //? draw_screen already draws the subscreen -DD
4996 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4997 8000 x=128-(((i*128/80)/8)*8);
4998
4999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(x>0)
5000 {
5001 8000 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5002 8000 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5003 8000 }
5004
5005 8000 advanceframe(true);
5006
5007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(Quit)
5008 {
5009 break;
5010 }
5011 8000 }
5012
5013 100 Hero.setDontDraw(false);
5014 100 show_subscreen_items=true;
5015 100 show_subscreen_dmap_dots=true;
5016 1009 }
5017
5018 void closescreen(int32_t shape)
5019 {
5020 reset_pal_cycling();
5021 black_opening_count=0;
5022
5023 if(COOLSCROLL || shape>-1)
5024 {
5025 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5026 return;
5027 }
5028 else
5029 {
5030 Hero.setDontDraw(true);
5031 show_subscreen_dmap_dots=false;
5032 show_subscreen_numbers=false;
5033 // show_subscreen_items=false;
5034 show_subscreen_life=false;
5035 }
5036
5037 int32_t x=128;
5038
5039 FFCore.warpScriptCheck();
5040 for(int32_t i=79; i>=0; --i)
5041 {
5042 draw_screen(tmpscr);
5043 //? draw_screen already draws the subscreen -DD
5044 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5045 x=128-(((i*128/80)/8)*8);
5046
5047 if(x>0)
5048 {
5049 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5050 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5051 }
5052
5053 advanceframe(true);
5054
5055 if(Quit)
5056 {
5057 break;
5058 }
5059 }
5060
5061 Hero.setDontDraw(false);
5062 show_subscreen_items=true;
5063 show_subscreen_dmap_dots=true;
5064 }
5065
5066 179 int32_t TriforceCount()
5067 {
5068 179 int32_t c=0;
5069
5070
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5071
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5072 1044 ++c;
5073
5074 179 return c;
5075 }
5076
5077 int32_t onCustomGame()
5078 {
5079 int32_t file = getsaveslot();
5080
5081 if(file < 0)
5082 return D_O_K;
5083
5084 bool ret = (custom_game(file)!=0);
5085 return ret ? D_CLOSE : D_O_K;
5086 }
5087
5088 int32_t onContinue()
5089 {
5090 return D_CLOSE;
5091 }
5092
5093 int32_t onEsc() // Unused?? -L
5094 {
5095 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5096 }
5097
5098 int32_t onVsync()
5099 {
5100 Throttlefps = !Throttlefps;
5101 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5102 return D_O_K;
5103 }
5104
5105 int32_t onWinPosSave()
5106 {
5107 SaveWinPos = !SaveWinPos;
5108 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5109 return D_O_K;
5110 }
5111 int32_t onIntegerScaling()
5112 {
5113 scaleForceInteger = !scaleForceInteger;
5114 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5115 return D_O_K;
5116 }
5117 int32_t onStretchGame()
5118 {
5119 stretchGame = !stretchGame;
5120 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5121 return D_O_K;
5122 }
5123
5124 int32_t onClickToFreeze()
5125 {
5126 ClickToFreeze = !ClickToFreeze;
5127 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5128 return D_O_K;
5129 }
5130
5131 int32_t OnSaveZCConfig()
5132 {
5133 if(jwin_alert3(
5134 "Save Configuration",
5135 "Are you sure that you wish to save your present configuration settings?",
5136 "This will overwrite your prior settings!",
5137 NULL,
5138 "&Yes",
5139 "&No",
5140 NULL,
5141 'y',
5142 'n',
5143 0,
5144 get_zc_font(font_lfont)) == 1)
5145 {
5146 save_game_configs();
5147 return D_O_K;
5148 }
5149 else return D_O_K;
5150 }
5151
5152 int32_t OnnClearQuestDir()
5153 {
5154 if(jwin_alert3(
5155 "Clear Current Directory Cache",
5156 "Are you sure that you wish to clear the current cached directory?",
5157 "This will default the current directory to `<ROOT>/quests` for this instance of ZC Player!",
5158 NULL,
5159 "&Yes",
5160 "&No",
5161 NULL,
5162 'y',
5163 'n',
5164 0,
5165 get_zc_font(font_lfont)) == 1)
5166 {
5167 zc_set_config("zeldadx","quest_dir","");
5168 flush_config_file();
5169 strcpy(qstdir,"");
5170 #ifdef __EMSCRIPTEN__
5171 em_sync_fs();
5172 #endif
5173 return D_O_K;
5174 }
5175 else return D_O_K;
5176 }
5177
5178
5179 int32_t onConsoleZASM()
5180 {
5181 if ( !zasm_debugger )
5182 {
5183 AlertDialog("WARNING: ZASM Debugger",
5184 "Enabling this will open the ZASM Debugger Console"
5185 "\nThis will likely grind ZC to a halt with lag."
5186 "\nTo make any use of this, it is suggested that you read"
5187 "\nthe documentation for 'void Breakpoint(char[] string);'"
5188 " in 'ZScript_Additions.txt'"
5189 "\nThis is not recommended for normal users,"
5190 " and is only intended for ZC developers,"
5191 "\nor quest developers coding directly in ZASM"
5192 "\nAre you sure that you wish to open the ZASM Debugger?",
5193 [&](bool ret,bool)
5194 {
5195 if(ret)
5196 {
5197 FFCore.ZASMPrint(true);
5198 }
5199 }).show();
5200 return D_O_K;
5201 }
5202 else
5203 {
5204 FFCore.ZASMPrint(false);
5205 return D_O_K;
5206 }
5207 }
5208
5209
5210 int32_t onConsoleZScript()
5211 {
5212 if ( !zscript_debugger )
5213 {
5214 AlertDialog("ZScript Debugger",
5215 "Enabling this will open the ZScript Debugger Console"
5216 "\nThis will display any messages logged by scripts,"
5217 " including script errors."
5218 "\nAre you sure that you wish to open the ZScript Debugger?",
5219 [&](bool ret,bool)
5220 {
5221 if(ret)
5222 {
5223 FFCore.ZScriptConsole(true);
5224 }
5225 }).show();
5226 return D_O_K;
5227 }
5228 else
5229 {
5230 FFCore.ZScriptConsole(false);
5231 return D_O_K;
5232 }
5233 }
5234
5235 int32_t onClrConsoleOnReload()
5236 {
5237 clearConsoleOnReload = !clearConsoleOnReload;
5238 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5239 return D_O_K;
5240 }
5241 int32_t onClrConsoleOnLoad()
5242 {
5243 clearConsoleOnLoad = !clearConsoleOnLoad;
5244 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5245 return D_O_K;
5246 }
5247
5248
5249 int32_t onFrameSkip()
5250 {
5251 FrameSkip = !FrameSkip;
5252 return D_O_K;
5253 }
5254
5255 int32_t onSaveDragResize()
5256 {
5257 SaveDragResize = !SaveDragResize;
5258 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5259 return D_O_K;
5260 }
5261
5262 int32_t onDragAspect()
5263 {
5264 DragAspect = !DragAspect;
5265 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5266 return D_O_K;
5267 }
5268
5269 int32_t onTransLayers()
5270 {
5271 TransLayers = !TransLayers;
5272 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5273 return D_O_K;
5274 }
5275
5276 int32_t onNESquit()
5277 {
5278 NESquit = !NESquit;
5279 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5280 return D_O_K;
5281 }
5282
5283 int32_t onVolKeys()
5284 {
5285 volkeys = !volkeys;
5286 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5287 return D_O_K;
5288 }
5289
5290 int32_t onShowFPS()
5291 {
5292 ShowFPS = !ShowFPS;
5293 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5294 return D_O_K;
5295 }
5296
5297 1095677554 bool is_Fkey(int32_t k)
5298 {
5299
2/2
✓ Branch 0 taken 111424836 times.
✓ Branch 1 taken 984252718 times.
1095677554 switch(k)
5300 {
5301 case KEY_F1:
5302 case KEY_F2:
5303 case KEY_F3:
5304 case KEY_F4:
5305 case KEY_F5:
5306 case KEY_F6:
5307 case KEY_F7:
5308 case KEY_F8:
5309 case KEY_F9:
5310 case KEY_F10:
5311 case KEY_F11:
5312 case KEY_F12:
5313 111424836 return true;
5314 }
5315
5316 984252718 return false;
5317 1095677554 }
5318
5319 void kb_getkey(DIALOG *d);
5320
5321 //Used by all keyboard key settings dialogues.
5322 void kb_clearjoystick(DIALOG *d)
5323 {
5324 d->flags|=D_SELECTED;
5325
5326 jwin_button_proc(MSG_DRAW,d,0);
5327 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5328 // text_mode(vc(11));
5329 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5330 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5331
5332 update_hw_screen(true);
5333
5334 clear_keybuf();
5335 int32_t k = next_press_key();
5336 clear_keybuf();
5337
5338 //shnarf
5339 //47=f1
5340 //59=esc
5341 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5342 // *((int32_t*)d->dp3) = k;
5343 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5344
5345
5346 d->flags&=~D_SELECTED;
5347 }
5348
5349 //Clears key to 0.
5350 //Used by all keyboard key settings dialogues.
5351 void kb_clearkey(DIALOG *d);
5352
5353 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5354 {
5355 switch(msg)
5356 {
5357 case MSG_KEY:
5358 case MSG_CLICK:
5359
5360 kb_clearjoystick(d);
5361
5362 while(gui_mouse_b())
5363 {
5364 clear_keybuf();
5365 rest(1);
5366 }
5367
5368 return D_REDRAW;
5369 }
5370
5371 return jwin_button_proc(msg,d,c);
5372 }
5373
5374 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5375 //Only used in keyboard settings dialogues to clear keys.
5376 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5377
5378 int32_t j_getbtn(DIALOG *d)
5379 {
5380 d->flags|=D_SELECTED;
5381 jwin_button_proc(MSG_DRAW,d,0);
5382 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5383 // text_mode(vc(11));
5384 int32_t y = screen->h/2 - 12;
5385 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5386 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5387 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5388
5389 update_hw_screen(true);
5390
5391 int32_t b = next_joy_input(true);
5392 if (b == -2)
5393 return D_CLOSE;
5394
5395 if(b>=0)
5396 *((int32_t*)d->dp3) = b;
5397
5398 d->flags&=~D_SELECTED;
5399
5400 if (player)
5401 player->joy_on = TRUE;
5402
5403 return D_O_K;
5404 }
5405
5406 void j_getstick(DIALOG *d)
5407 {
5408 d->flags|=D_SELECTED;
5409 jwin_button_proc(MSG_DRAW,d,0);
5410 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5411 // text_mode(vc(11));
5412 int32_t y = screen->h/2 - 12;
5413 textout_centre_ex(screen, font, "Move a stick (or DPAD)", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5414 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5415 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5416
5417 update_hw_screen(true);
5418
5419 int32_t b = next_joy_input(false);
5420
5421 if(b>=0)
5422 *((int32_t*)d->dp3) = b;
5423
5424 d->flags&=~D_SELECTED;
5425
5426 if (player)
5427 player->joy_on = TRUE;
5428 }
5429
5430 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5431 {
5432 switch(msg)
5433 {
5434 case MSG_KEY:
5435 case MSG_CLICK:
5436
5437 int ret = j_getbtn(d);
5438 if (ret != D_O_K)
5439 return ret;
5440
5441 while(gui_mouse_b()) {
5442 rest(1);
5443 clear_keybuf();
5444 }
5445
5446 return D_REDRAW;
5447 }
5448
5449 return jwin_button_proc(msg,d,c);
5450 }
5451
5452 int32_t d_jstick_proc(int32_t msg,DIALOG *d,int32_t c)
5453 {
5454 switch(msg)
5455 {
5456 case MSG_KEY:
5457 case MSG_CLICK:
5458
5459 j_getstick(d);
5460
5461 while(gui_mouse_b()) {
5462 rest(1);
5463 clear_keybuf();
5464 }
5465
5466 return D_REDRAW;
5467 }
5468
5469 return jwin_button_proc(msg,d,c);
5470 }
5471
5472 //shnarf
5473 extern const char *key_str[];
5474 std::string get_keystr(int key);
5475
5476 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5477 //extern int32_t zcmusic_bufsz;
5478
5479 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5480 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80],
5481 str_primary_stick[80], str_secondary_stick[80];
5482
5483 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5484 {
5485 //these are here to bypass compiler warnings about unused arguments
5486 c=c;
5487
5488 if (d->w == 1)
5489 {
5490 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
5491 {
5492 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
5493 return D_CLOSE;
5494 }
5495 }
5496
5497 if(msg==MSG_DRAW)
5498 {
5499 switch(d->w)
5500 {
5501 case 0:
5502 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5503 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5504 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5505 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5506 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5507 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5508 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5509 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5510 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5511 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5512 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5513 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5514 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5515 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5516 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5517 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5518 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5519 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5520 break;
5521
5522 case 1:
5523 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5524 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5525 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5526 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5527 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5528 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5529 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5530 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5531 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5532 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5533 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5534 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5535 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5536 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5537 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5538 sprintf(str_primary_stick,"%03d\n%s",js_stick_1_x_stick,joystick_name(js_stick_1_x_stick));
5539 sprintf(str_secondary_stick,"%03d\n%s",js_stick_2_x_stick,joystick_name(js_stick_2_x_stick));
5540 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5541 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5542 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5543 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5544 break;
5545
5546 case 2:
5547 sprintf(str_a," %3d",midi_volume);
5548 sprintf(str_b," %3d",digi_volume);
5549 sprintf(str_l," %3d",emusic_volume);
5550 sprintf(str_m," %3dKB",zcmusic_bufsz);
5551 sprintf(str_r," %3d",sfx_volume);
5552 strcpy(str_s,pan_str[pan_style]);
5553 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5554 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5555 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5556 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5557 break;
5558 }
5559 }
5560
5561 return D_O_K;
5562 }
5563
5564 int32_t set_vol(void *dp3, int32_t d2)
5565 {
5566 switch(((int32_t*)dp3)[0])
5567 {
5568 case 0:
5569 midi_volume = zc_min(d2<<3,255);
5570 break;
5571
5572 case 1:
5573 digi_volume = zc_min(d2<<3,255);
5574 break;
5575
5576 case 2:
5577 emusic_volume = zc_min(d2<<3,255);
5578 break;
5579
5580 case 3:
5581 sfx_volume = zc_min(d2<<3,255);
5582 break;
5583 }
5584
5585 // text_mode(vc(11));
5586 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5587 return D_O_K;
5588 }
5589
5590 int32_t set_pan(void *dp3, int32_t d2)
5591 {
5592 pan_style = vbound(d2,0,3);
5593 // text_mode(vc(11));
5594 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5595 return D_O_K;
5596 }
5597
5598 int32_t set_buf(void *dp3, int32_t d2)
5599 {
5600 // text_mode(vc(11));
5601 zcmusic_bufsz = d2 + 1;
5602 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5603 return D_O_K;
5604 }
5605
5606 static int32_t gamepad_joys_list[] =
5607 {
5608 61,
5609 -1
5610 };
5611
5612 static int32_t gamepad_btn_list[] =
5613 {
5614 6,
5615 7,8,9,10,11,12,13,14,15,16,17,
5616 18,19,20,21,22,23,24,25,26,27,28,
5617 29,30,31,32,33,34,35,36,37,38,39,
5618 -1
5619 };
5620
5621 static int32_t gamepad_dirs_list[] =
5622 {
5623 40,41,42,43,
5624 44,45,46,47,
5625 48,49,50,51,
5626 52,53,54,55,
5627 56,57,58,59,
5628 60,
5629 -1
5630 };
5631
5632 static TABPANEL gamepad_tabs[] =
5633 {
5634 // (text)
5635 { (char *)"Controllers", D_SELECTED, gamepad_joys_list, 0, NULL },
5636 { (char *)"Buttons", 0, gamepad_btn_list, 0, NULL },
5637 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5638 { NULL, 0, NULL, 0, NULL }
5639 };
5640
5641 const char *joy_list(int32_t index, int32_t *list_size)
5642 {
5643 if (index == -1)
5644 {
5645 *list_size = al_get_num_joysticks();
5646 return NULL;
5647 }
5648
5649 ALLEGRO_JOYSTICK* joy = al_get_joystick(index);
5650 if (!joy)
5651 {
5652 return "?";
5653 }
5654
5655 return al_get_joystick_name(joy);
5656 }
5657
5658 114 static ListData joy__list(joy_list, &font);
5659
5660 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c)
5661 {
5662 int32_t d2 = d->d2;
5663 int32_t ret = jwin_droplist_proc(msg,d,c);
5664
5665 if(d2!=d->d2)
5666 {
5667 joystick_index = d->d2;
5668 ret |= D_REDRAW_ALL;
5669 }
5670
5671 return ret;
5672 }
5673
5674 static DIALOG gamepad_dlg[] =
5675 {
5676 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5677 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5678 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5679 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5680 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5681 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5682 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5683 // 6
5684 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5685 // 7
5686 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5687 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5688 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5689 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5690 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5691 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5692 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5693 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5694 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5695 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5696 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5697 // 18
5698 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5699 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5700 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5701 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5702 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5703 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5704 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5705 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5706 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5707 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5708 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5709 // 29
5710 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5711 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5712 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5713 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5714 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5715 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5716 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5717 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5718 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5719 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5720 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5721 // 40
5722 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5723 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5724 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5725 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5726 // 44
5727 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5728 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5729 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5730 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5731 // 48
5732 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5733 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5734 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5735 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5736 // 52
5737 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5738 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5739 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5740 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5741 // 56
5742 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Primary: Use Analog Stick (Ignore above and use below instead)", NULL, NULL },
5743 { d_jstick_proc, 22, 165, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Primary", NULL, &js_stick_1_x_stick },
5744 { d_jstick_proc, 22, 195, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Secondary", NULL, &js_stick_2_x_stick },
5745 { jwin_text_proc, 90, 165, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_primary_stick, NULL, NULL },
5746 { jwin_text_proc, 90, 195, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_secondary_stick, NULL, NULL },
5747
5748 // 61
5749 { d_joylist_proc, 22, 62, 150, 16, 0, 0, 0, 0, 0, 0, (void *) &joy__list, NULL, NULL },
5750
5751 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5752 };
5753
5754 static int32_t keyboard_keys_list[] =
5755 {
5756 6,7,8,9,10,
5757 11,12,13,14,15,16,17,18,19,20,
5758 21,22,23,24,25,26,27,28,29,30,
5759 31,32,33,34,35,36,37,38,39,40,
5760 -1
5761 };
5762
5763 static int32_t keyboard_dirs_list[] =
5764 {
5765 41,42,43,44,
5766 45,46,47,48,
5767 49,50,51,52,
5768 53,54,55,56,
5769 -1
5770 };
5771
5772 static int32_t keyboard_mods_list[] =
5773 {
5774 57,58,59,60,
5775 61,62,63,64,
5776 65,66,67,68,
5777 69,70,71,72,
5778 -1
5779 };
5780
5781 static TABPANEL keyboard_control_tabs[] =
5782 {
5783 // (text)
5784 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5785 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5786 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5787 { NULL, 0, NULL, 0, NULL }
5788 };
5789
5790 static DIALOG keyboard_control_dlg[] =
5791 {
5792 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5793 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5794 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5795 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5796 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5797 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5798 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5799 // Keys
5800 // 6
5801 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5802 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5803 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5804 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5805 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5806 // 11
5807 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5808 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5809 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5810 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5811 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5812 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5813 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5814 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5815 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5816 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5817 // 21
5818 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5819 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5820 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5821 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5822 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5823 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5824 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5825 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5826 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5827 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5828 // 31
5829 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5830 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5831 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5832 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5833 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5834 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5835 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5836 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5837 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5838 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5839 // Dirs
5840 // 41
5841 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5842 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5843 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5844 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5845 // 45
5846 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5847 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5848 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5849 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5850 // 49
5851 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5852 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5853 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5854 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5855 // 53
5856 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5857 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5858 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5859 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5860 // Mods
5861 // 57
5862 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5863 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5864 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5865 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5866 // 61
5867 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5868 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5869 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5870 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5871 // 65
5872 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5873 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5874 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5875 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5876 // 69
5877 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5878 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5879 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5880 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5881 // 73
5882 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5883 };
5884
5885 /*
5886 int32_t midi_dp[3] = {0,147,104};
5887 int32_t digi_dp[3] = {1,147,120};
5888 int32_t pan_dp[3] = {0,147,136};
5889 int32_t buf_dp[3] = {0,147,152};
5890 */
5891 int32_t midi_dp[3] = {0,0,0};
5892 int32_t digi_dp[3] = {1,0,0};
5893 int32_t emus_dp[3] = {2,0,0};
5894 int32_t buf_dp[3] = {0,0,0};
5895 int32_t sfx_dp[3] = {3,0,0};
5896 int32_t pan_dp[3] = {0,0,0};
5897
5898 static DIALOG sound_dlg[] =
5899 {
5900 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5901 114 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5902 114 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5903 114 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5904 114 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5905 114 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5906 114 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5907 114 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5908 114 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5909 114 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5910 114 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5911 // 10
5912 114 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5913 114 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5914 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5915 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5916 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5917 114 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5918 114 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5919 114 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5920 114 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5921 114 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5922 //20
5923 114 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5924 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5925 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5926 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5927 114 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5928 114 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5929 114 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5930 114 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5931 114 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5932 114 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5933 //30
5934 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5935 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5936 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5937 114 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5938 };
5939
5940 char zc_builddate[80];
5941 char zc_aboutstr[80];
5942
5943 static DIALOG about_dlg[] =
5944 {
5945 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5946 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5947 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5948 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5949 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5950 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5951 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5952 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5953 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5954 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5955 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5956 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5957 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5958 };
5959
5960
5961 static DIALOG quest_dlg[] =
5962 {
5963 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5964 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5965 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5966 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5967 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5968 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5969 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5970 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5971 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5972 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5973 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5974 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5975 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5976 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5977 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5978 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5979 };
5980
5981 static DIALOG triforce_dlg[] =
5982 {
5983 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5984 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5985 // 1
5986 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5987 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5988 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5989 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5990 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5991 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5992 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5993 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5994 // 9
5995 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5996 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5997 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5998 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5999 };
6000
6001 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6002 {
6003 go();
6004 int32_t ret=0;
6005 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6006 comeback();
6007 return ret != 0;
6008 }
6009
6010
6011 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6012 {
6013 if(def!=modulepath)
6014 strcpy(modulepath,def);
6015
6016 if(!usefilename)
6017 {
6018 int32_t i=(int32_t)strlen(modulepath);
6019
6020 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6021 modulepath[i--]=0;
6022 }
6023
6024 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6025 int32_t ret=0;
6026 int32_t sel=0;
6027
6028 if(list==NULL)
6029 {
6030 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
6031 }
6032 else
6033 {
6034 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
6035 }
6036
6037 return ret!=0;
6038 }
6039
6040 int32_t onToggleRecordingNewSaves()
6041 {
6042 if (zc_get_config("zeldadx", "replay_new_saves", false))
6043 {
6044 zc_set_config("zeldadx", "replay_new_saves", false);
6045 }
6046 else
6047 {
6048 zc_set_config("zeldadx", "replay_new_saves", true);
6049 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6050 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6051 }
6052 return D_O_K;
6053 }
6054
6055 int32_t onToggleSnapshotAllFrames()
6056 {
6057 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6058 return D_O_K;
6059 }
6060
6061 int32_t onStopReplayOrRecord()
6062 {
6063 if (replay_is_replaying())
6064 {
6065 replay_quit();
6066 }
6067 else if (replay_get_mode() == ReplayMode::Record)
6068 {
6069 if (!replay_get_meta_bool("test_mode"))
6070 {
6071 jwin_alert("Recording", "You cannot stop recording a save file.",
6072 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6073 return D_CLOSE;
6074 }
6075
6076 if (jwin_alert("Stop Recording",
6077 "Save replay to disk and stop recording?",
6078 "This will stop the recording.",
6079 NULL,
6080 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6081 return D_CLOSE;
6082
6083 replay_save();
6084 replay_stop();
6085 }
6086 return D_O_K;
6087 }
6088
6089 static int32_t handle_on_load_replay(ReplayMode mode)
6090 {
6091 if (Playing)
6092 {
6093 if (jwin_alert("Replay - Warning!",
6094 "Loading a replay will exit the current game.",
6095 "All unsaved progress will be lost.",
6096 "Do you wish to continue?",
6097 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6098 return D_CLOSE;
6099 }
6100
6101 std::string mode_string = replay_mode_to_string(mode);
6102 mode_string[0] = std::toupper(mode_string[0]);
6103
6104 std::string line_1 = "Select a replay file to play back.";
6105 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6106 std::string line_3 = "You can stop the replay and take over manually any time.";
6107 if (mode == ReplayMode::Update)
6108 {
6109 line_1 = "Select a replay file to update.";
6110 line_2 = "WARNING: be sure to back up the zplay file";
6111 line_3 = "and verify that the updated replay works as expected!";
6112 }
6113
6114 if (jwin_alert(mode_string.c_str(),
6115 line_1.c_str(),
6116 line_2.c_str(),
6117 line_3.c_str(),
6118 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6119 {
6120 char replay_path[2048];
6121 strcpy(replay_path, "replays/");
6122 if (jwin_file_select_ex(
6123 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6124 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6125 return D_CLOSE;
6126
6127 replay_quit();
6128 load_replay_file_deferred(mode, replay_path);
6129 Quit = qRESET;
6130 return D_CLOSE;
6131 }
6132 return D_O_K;
6133 }
6134
6135 int32_t onLoadReplay()
6136 {
6137 return handle_on_load_replay(ReplayMode::Replay);
6138 }
6139
6140 int32_t onLoadReplayAssert()
6141 {
6142 return handle_on_load_replay(ReplayMode::Assert);
6143 }
6144
6145 int32_t onLoadReplayUpdate()
6146 {
6147 return handle_on_load_replay(ReplayMode::Update);
6148 }
6149
6150 int32_t onSaveReplay()
6151 {
6152 if (replay_get_mode() == ReplayMode::Record)
6153 {
6154 if (!replay_get_meta_bool("test_mode"))
6155 {
6156 if (jwin_alert("Save Replay",
6157 "This will save a copy of the replay up to this point.",
6158 "The official replay file will be untouched.",
6159 "Do you wish to continue?",
6160 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6161 return D_CLOSE;
6162
6163 char replay_path[2048];
6164 strcpy(replay_path, replay_get_replay_path().string().c_str());
6165 if (jwin_file_select_ex(
6166 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6167 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6168 return D_CLOSE;
6169
6170 if (fileexists(replay_path))
6171 {
6172 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6173 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6174 return D_CLOSE;
6175 }
6176
6177 replay_save(replay_path);
6178 }
6179 else
6180 {
6181 replay_save();
6182 }
6183 }
6184 return D_O_K;
6185 }
6186
6187 static MENU replay_menu[] =
6188 {
6189 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6190 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6191 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6192 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6193 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6194 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6195 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6196
6197 { NULL, NULL, NULL, 0, NULL }
6198 };
6199
6200 static DIALOG credits_dlg[] =
6201 {
6202 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6203 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6204 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6205 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6206 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6207 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6208 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6209 };
6210
6211 114 static ListData dmap_list(dmaplist, &font);
6212
6213 static DIALOG goto_dlg[] =
6214 {
6215 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6216 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6217 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6218 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6219 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6220 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6221 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6222 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6223 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6224 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6225 };
6226
6227 int32_t onGoTo()
6228 {
6229 bool music = false;
6230 music = music;
6231 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6232
6233 goto_dlg[0].dp2=get_zc_font(font_lfont);
6234 goto_dlg[4].d2=cheat_goto_dmap;
6235 goto_dlg[6].dp=cheat_goto_screen_str;
6236
6237 clear_keybuf();
6238
6239 large_dialog(goto_dlg);
6240
6241 if(do_zqdialog(goto_dlg,4)==1)
6242 {
6243 // dmap, screen
6244 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6245 };
6246
6247 return D_O_K;
6248 }
6249
6250 int32_t onGoToComplete()
6251 {
6252 if(!Playing)
6253 {
6254 return D_O_K;
6255 }
6256
6257 enter_sys_pal();
6258 music_pause();
6259 pause_all_sfx();
6260 onGoTo();
6261 eat_buttons();
6262
6263 zc_readrawkey(KEY_ESC);
6264
6265 exit_sys_pal();
6266 music_resume();
6267 resume_all_sfx();
6268 return D_O_K;
6269 }
6270
6271 int32_t onCredits()
6272 {
6273 return D_O_K;
6274 }
6275
6276 const char *midilist(int32_t index, int32_t *list_size)
6277 {
6278 if(index<0)
6279 {
6280 *list_size=0;
6281
6282 for(int32_t i=0; i<MAXMIDIS; i++)
6283 if(tunes[i].data)
6284 ++(*list_size);
6285
6286 return NULL;
6287 }
6288
6289 int32_t i=0,m=0;
6290
6291 while(m<=index && i<=MAXMIDIS)
6292 {
6293 if(tunes[i].data)
6294 ++m;
6295
6296 ++i;
6297 }
6298
6299 --i;
6300
6301 if(i==MAXMIDIS && m<index)
6302 return "(null)";
6303
6304 return tunes[i].title;
6305 }
6306
6307 /* ------- MIDI info stuff -------- */
6308
6309 char *text;
6310 midi_info *zmi;
6311 bool dialog_running;
6312 bool listening;
6313
6314 void get_info(int32_t index);
6315
6316 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6317 {
6318 int32_t d2 = d->d2;
6319 int32_t ret = jwin_droplist_proc(msg,d,c);
6320
6321 if(d2!=d->d2)
6322 {
6323 get_info(d->d2);
6324 }
6325
6326 return ret;
6327 }
6328
6329 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6330 {
6331 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6332
6333 int32_t ret = jwin_button_proc(msg,d,c);
6334
6335 if(ret == D_CLOSE)
6336 {
6337 // get current midi index
6338 int32_t index = (d+(d->d1))->d2;
6339 int32_t i=0, m=0;
6340
6341 while(m<=index && i<=MAXMIDIS)
6342 {
6343 if(tunes[i].data)
6344 ++m;
6345
6346 ++i;
6347 }
6348
6349 --i;
6350 jukebox(i);
6351 listening = true;
6352 ret = D_O_K;
6353 }
6354
6355 return ret;
6356 }
6357
6358 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6359 {
6360 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6361
6362 int32_t ret = jwin_button_proc(msg,d,c);
6363
6364 if(ret == D_CLOSE)
6365 {
6366 // get current midi index
6367 int32_t index = (d+(d->d1))->d2;
6368 int32_t i=0, m=0;
6369
6370 while(m<=index && i<=MAXMIDIS)
6371 {
6372 if(tunes[i].data)
6373 ++m;
6374
6375 ++i;
6376 }
6377
6378 --i;
6379
6380 // get file name
6381
6382 int32_t sel=0;
6383 //struct ffblk f;
6384 char title[40] = "Save MIDI: ";
6385 char fname[2048];
6386 memset(fname,0,2048);
6387 static EXT_LIST list[] =
6388 {
6389 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6390 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6391 { NULL, NULL }
6392 };
6393
6394 strcpy(title+11, tunes[i].title);
6395 title[39] = '\0';
6396
6397 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6398 goto done;
6399
6400 if(exists(fname))
6401 {
6402 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6403 goto done;
6404 }
6405
6406 // save midi i
6407
6408 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6409 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6410
6411 done:
6412 chop_path(fname);
6413 ret = D_REDRAW;
6414 }
6415
6416 return ret;
6417 }
6418
6419 114 static ListData midi_list(midilist, &font);
6420
6421 static DIALOG midi_dlg[] =
6422 {
6423 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6424 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6425 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6426 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6427 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6428 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6429 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6430 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6431 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6432 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6433 };
6434
6435 void get_info(int32_t index)
6436 {
6437 int32_t i=0, m=0;
6438
6439 while(m<=index && i<=MAXMIDIS)
6440 {
6441 if(tunes[i].data)
6442 ++m;
6443
6444 ++i;
6445 }
6446
6447 --i;
6448
6449 if(i==MAXMIDIS && m<index)
6450 strcpy(text,"(null)");
6451 else
6452 {
6453 get_midi_info((MIDI*)tunes[i].data,zmi);
6454 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6455 }
6456
6457 midi_dlg[0].dp2=get_zc_font(font_lfont);
6458 midi_dlg[3].dp = text;
6459 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6460 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6461
6462 if(dialog_running)
6463 {
6464 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6465 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6466 }
6467 }
6468
6469 int32_t onMIDICredits()
6470 {
6471 text = (char*)malloc(4096);
6472 zmi = (midi_info*)malloc(sizeof(midi_info));
6473
6474 if(!text || !zmi)
6475 {
6476 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6477 return D_O_K;
6478 }
6479
6480 bool do_pause_midi = midi_pos >= 0 && currmidi;
6481 auto restore_midi = currmidi;
6482 if(do_pause_midi)
6483 {
6484 paused_midi_pos = midi_pos;
6485 stop_midi();
6486 midi_suspended = midissuspHALTED;
6487 }
6488
6489 midi_dlg[0].dp2=get_zc_font(font_lfont);
6490 midi_dlg[2].d1 = 0;
6491 midi_dlg[2].d2 = 0;
6492 midi_dlg[4].flags = D_EXIT;
6493 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6494
6495 listening = false;
6496 dialog_running=false;
6497 get_info(0);
6498
6499 dialog_running=true;
6500
6501 large_dialog(midi_dlg);
6502
6503 do_zqdialog(midi_dlg,0);
6504 dialog_running=false;
6505
6506 if(listening)
6507 music_stop();
6508
6509 if(do_pause_midi)
6510 {
6511 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6512 midi_suspended = midissuspRESUME;
6513 currmidi = restore_midi;
6514 midi_pos = paused_midi_pos;
6515 }
6516
6517 if(text) free(text);
6518 if(zmi) free(zmi);
6519 return D_O_K;
6520 }
6521
6522 int32_t onAbout()
6523 {
6524 char buf1[80]={0};
6525 std::ostringstream oss;
6526 sprintf(buf1,"%s, Version: %s", ZC_PLAYER_NAME,ZC_PLAYER_V);
6527 oss << buf1 << '\n';
6528 sprintf(buf1, "%s", ALPHA_VER_STR);
6529 oss << buf1 << '\n';
6530 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6531 oss << buf1 << '\n';
6532 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6533 oss << buf1 << '\n';
6534 sprintf(buf1, "Tag: %s", getReleaseTag());
6535 oss << buf1 << '\n';
6536
6537 InfoDialog("About ZC", oss.str()).show();
6538 return D_O_K;
6539 }
6540
6541 int32_t onQuest()
6542 {
6543 char fname[100];
6544 strcpy(fname, get_filename(qstpath));
6545 quest_dlg[0].dp2=get_zc_font(font_lfont);
6546 quest_dlg[1].dp = fname;
6547
6548 if(QHeader.quest_number==0)
6549 sprintf(str_a,"Custom");
6550 else
6551 sprintf(str_a,"%d",QHeader.quest_number);
6552
6553 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6554
6555 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6556 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6557
6558 large_dialog(quest_dlg);
6559
6560 do_zqdialog(quest_dlg, 0);
6561 return D_O_K;
6562 }
6563
6564 void call_vidmode_dlg();
6565 int32_t onVidMode()
6566 {
6567 call_vidmode_dlg();
6568 return D_O_K;
6569 }
6570
6571 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6572 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6573 //Added an extra statement, so that if the key is cleared to 0, the cleared
6574 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6575
6576 void load_ukeys(int32_t* arr)
6577 {
6578 arr[ukey_a] = Akey;
6579 arr[ukey_b] = Bkey;
6580 arr[ukey_s] = Skey;
6581 arr[ukey_l] = Lkey;
6582 arr[ukey_r] = Rkey;
6583 arr[ukey_p] = Pkey;
6584 arr[ukey_ex1] = Exkey1;
6585 arr[ukey_ex2] = Exkey2;
6586 arr[ukey_ex3] = Exkey3;
6587 arr[ukey_ex4] = Exkey4;
6588 arr[ukey_du] = DUkey;
6589 arr[ukey_dd] = DDkey;
6590 arr[ukey_dl] = DLkey;
6591 arr[ukey_dr] = DRkey;
6592 arr[ukey_mod1a] = cheat_modifier_keys[0];
6593 arr[ukey_mod1b] = cheat_modifier_keys[1];
6594 arr[ukey_mod2a] = cheat_modifier_keys[2];
6595 arr[ukey_mod2b] = cheat_modifier_keys[3];
6596 };
6597
6598 static const char* ukey_names[] = {
6599 "A", "B", "Start", "L", "R", "Map",
6600 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6601 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6602 "Cheat Mod R1", "Cheat Mod R2",
6603 };
6604 std::string get_ukey_name(int32_t k)
6605 {
6606 if (k < num_ukey) return ukey_names[k];
6607 return "";
6608 }
6609
6610 int32_t onKeyboard()
6611 {
6612 int32_t a = Akey;
6613 int32_t b = Bkey;
6614 int32_t s = Skey;
6615 int32_t l = Lkey;
6616 int32_t r = Rkey;
6617 int32_t p = Pkey;
6618 int32_t ex1 = Exkey1;
6619 int32_t ex2 = Exkey2;
6620 int32_t ex3 = Exkey3;
6621 int32_t ex4 = Exkey4;
6622 int32_t du = DUkey;
6623 int32_t dd = DDkey;
6624 int32_t dl = DLkey;
6625 int32_t dr = DRkey;
6626 int32_t mod1a = cheat_modifier_keys[0];
6627 int32_t mod1b = cheat_modifier_keys[1];
6628 int32_t mod2a = cheat_modifier_keys[2];
6629 int32_t mod2b = cheat_modifier_keys[3];
6630 bool done=false;
6631 int32_t ret;
6632
6633 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6634
6635 large_dialog(keyboard_control_dlg);
6636
6637 while(!done)
6638 {
6639 ret = do_zqdialog(keyboard_control_dlg,3);
6640
6641 if(ret==3) // OK
6642 {
6643 int32_t ukeys[num_ukey];
6644 load_ukeys(ukeys);
6645 std::vector<std::string> uniqueError;
6646 for(int32_t q = 0; q < num_ukey; ++q)
6647 {
6648 for(int32_t p = q+1; p < num_ukey; ++p)
6649 {
6650 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6651 {
6652 char buf[64];
6653 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6654 std::string str(buf);
6655 uniqueError.push_back(str);
6656 }
6657 }
6658 }
6659 if(uniqueError.size() == 0)
6660 {
6661 done = true;
6662 save_control_configs(true);
6663 }
6664 else
6665 {
6666 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6667 box_out("Cannot have duplicate keybinds!"); box_eol();
6668 for(std::vector<std::string>::iterator it = uniqueError.begin();
6669 it != uniqueError.end(); ++it)
6670 {
6671 box_out((*it).c_str()); box_eol();
6672 }
6673 box_end(true);
6674 }
6675 }
6676 else // Cancel
6677 {
6678 Akey = a;
6679 Bkey = b;
6680 Skey = s;
6681 Lkey = l;
6682 Rkey = r;
6683 Pkey = p;
6684 Exkey1 = ex1;
6685 Exkey2 = ex2;
6686 Exkey3 = ex3;
6687 Exkey4 = ex4;
6688 DUkey = du;
6689 DDkey = dd;
6690 DLkey = dl;
6691 DRkey = dr;
6692 cheat_modifier_keys[0] = mod1a;
6693 cheat_modifier_keys[1] = mod1b;
6694 cheat_modifier_keys[2] = mod2a;
6695 cheat_modifier_keys[3] = mod2b;
6696
6697 done=true;
6698 }
6699
6700 rest(1);
6701 }
6702
6703 return D_O_K;
6704 }
6705
6706 int32_t onGamepad()
6707 {
6708 if (al_get_num_joysticks() == 0)
6709 {
6710 InfoDialog("ZC", "No gamepads detected.").show();
6711 return D_O_K;
6712 }
6713
6714 int32_t a = Abtn;
6715 int32_t b = Bbtn;
6716 int32_t s = Sbtn;
6717 int32_t l = Lbtn;
6718 int32_t r = Rbtn;
6719 int32_t m = Mbtn;
6720 int32_t p = Pbtn;
6721 int32_t ex1 = Exbtn1;
6722 int32_t ex2 = Exbtn2;
6723 int32_t ex3 = Exbtn3;
6724 int32_t ex4 = Exbtn4;
6725 int32_t up = DUbtn;
6726 int32_t down = DDbtn;
6727 int32_t left = DLbtn;
6728 int32_t right = DRbtn;
6729 int32_t joy = joystick_index;
6730 int32_t stick_1 = js_stick_1_x_stick;
6731 int32_t stick_2 = js_stick_2_x_stick;
6732
6733 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6734 if(analog_movement)
6735 gamepad_dlg[56].flags|=D_SELECTED;
6736 else
6737 gamepad_dlg[56].flags&=~D_SELECTED;
6738
6739 // TODO: should use controller device GUID or name instead of index, otherwise this value is not
6740 // consistent unless exact same number of joysticks is always connected. Name is problematic b/c
6741 // xinput driver doesn't actually get a name (at least, doesn't for my Xbox controller).
6742 // TODO: should store gamepad control mappings per-controller, otherwise switching joystick
6743 // requires remapping every time.
6744 if (joystick_index >= al_get_num_joysticks())
6745 joystick_index = 0;
6746 gamepad_dlg[61].d2 = joystick_index;
6747
6748 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6749 if (!gamepad_dlg_cur_joystick)
6750 {
6751 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6752 return D_CLOSE;
6753 }
6754
6755 large_dialog(gamepad_dlg);
6756
6757 int32_t ret = do_zqdialog(gamepad_dlg,4);
6758
6759 if(ret == 4) //OK
6760 {
6761 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6762 joystick_index = gamepad_dlg[61].d2;
6763 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6764 if (!gamepad_dlg_cur_joystick)
6765 {
6766 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6767 return D_CLOSE;
6768 }
6769 js_stick_1_y_stick = js_stick_1_x_stick;
6770 js_stick_2_y_stick = js_stick_2_x_stick;
6771 save_control_configs(false);
6772 }
6773 else //Cancel
6774 {
6775 Abtn = a;
6776 Bbtn = b;
6777 Sbtn = s;
6778 Lbtn = l;
6779 Rbtn = r;
6780 Mbtn = m;
6781 Pbtn = p;
6782 Exbtn1 = ex1;
6783 Exbtn2 = ex2;
6784 Exbtn3 = ex3;
6785 Exbtn4 = ex4;
6786 DUbtn = up;
6787 DDbtn = down;
6788 DLbtn = left;
6789 DRbtn = right;
6790 joystick_index = joy;
6791 js_stick_1_x_stick = stick_1;
6792 js_stick_2_x_stick = stick_2;
6793 }
6794
6795 return D_O_K;
6796 }
6797
6798 int32_t onCheatKeys()
6799 {
6800 int32_t oldcheats[Cheat::Last][2];
6801 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6802
6803 bool done=false;
6804
6805 while(!done)
6806 {
6807 bool confirm = false;
6808 CheatKeysDialog(&confirm).show();
6809 if(confirm) // OK
6810 {
6811 std::vector<std::string> uniqueError;
6812 char buf[512];
6813 for(size_t q = 1; q < Cheat::Last; ++q)
6814 {
6815 if(cheatkeys[q][1] && !cheatkeys[q][0])
6816 {
6817 cheatkeys[q][0] = cheatkeys[q][1];
6818 cheatkeys[q][1] = 0;
6819 }
6820 }
6821 for(size_t q = 1; q < Cheat::Last; ++q)
6822 {
6823 if(!bindable_cheat((Cheat)q)) continue;
6824 for(size_t p = q+1; p < Cheat::Last; ++p)
6825 {
6826 if(!bindable_cheat((Cheat)p)) continue;
6827 for(size_t q2 = 0; q2 <= 1; ++q2)
6828 for(size_t p2 = 0; p2 <= 1; ++p2)
6829 {
6830 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6831 {
6832 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6833 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6834 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6835 get_keystr(cheatkeys[q][q2])));
6836 }
6837 }
6838 }
6839 }
6840 if(uniqueError.size() == 0)
6841 {
6842 done = true;
6843 save_cheatkeys();
6844 }
6845 else
6846 {
6847 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6848 box_out("Cannot have duplicate keybinds!"); box_eol();
6849 for(std::vector<std::string>::iterator it = uniqueError.begin();
6850 it != uniqueError.end(); ++it)
6851 {
6852 box_out((*it).c_str()); box_eol();
6853 }
6854 box_end(true);
6855 }
6856 }
6857 else // Cancel
6858 {
6859 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6860 done=true;
6861 }
6862 rest(1);
6863 }
6864
6865 return D_O_K;
6866 }
6867
6868 int32_t onSound()
6869 {
6870 if (get_qr(qr_OLD_SCRIPT_VOLUME))
6871 {
6872 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
6873 {
6874 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
6875 }
6876 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
6877 {
6878 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
6879 }
6880 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
6881 {
6882 emusic_volume = (int32_t)FFCore.usr_music_volume;
6883 }
6884 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
6885 {
6886 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6887 }
6888 }
6889 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6890 {
6891 pan_style = (int32_t)FFCore.usr_panstyle;
6892 }
6893
6894 int32_t m = midi_volume;
6895 int32_t d = digi_volume;
6896 int32_t e = emusic_volume;
6897 int32_t b = zcmusic_bufsz;
6898 int32_t s = sfx_volume;
6899 int32_t p = pan_style;
6900 pan_style = vbound(pan_style,0,3);
6901
6902 sound_dlg[0].dp2=get_zc_font(font_lfont);
6903
6904 large_dialog(sound_dlg);
6905
6906 midi_dp[1] = sound_dlg[6].x;
6907 midi_dp[2] = sound_dlg[6].y;
6908 digi_dp[1] = sound_dlg[7].x;
6909 digi_dp[2] = sound_dlg[7].y;
6910 emus_dp[1] = sound_dlg[8].x;
6911 emus_dp[2] = sound_dlg[8].y;
6912 buf_dp[1] = sound_dlg[9].x;
6913 buf_dp[2] = sound_dlg[9].y;
6914 sfx_dp[1] = sound_dlg[10].x;
6915 sfx_dp[2] = sound_dlg[10].y;
6916 pan_dp[1] = sound_dlg[11].x;
6917 pan_dp[2] = sound_dlg[11].y;
6918 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6919 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6920 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6921 sound_dlg[18].d2 = zcmusic_bufsz;
6922 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6923 sound_dlg[20].d2 = pan_style;
6924
6925 int32_t ret = do_zqdialog(sound_dlg,1);
6926
6927 if(ret==2)
6928 {
6929 master_volume(digi_volume,midi_volume);
6930 if (zcmusic)
6931 zcmusic_set_volume(zcmusic, emusic_volume);
6932
6933 int32_t temp_volume = sfx_volume;
6934 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
6935 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
6936 for(int32_t i=0; i<WAV_COUNT; ++i)
6937 {
6938 //allegro assertion fails when passing in -1 as voice -DD
6939 if(sfx_voice[i] > 0)
6940 voice_set_volume(sfx_voice[i], temp_volume);
6941 }
6942 zc_set_config(sfx_sect,"digi",digi_volume);
6943 zc_set_config(sfx_sect,"midi",midi_volume);
6944 zc_set_config(sfx_sect,"sfx",sfx_volume);
6945 zc_set_config(sfx_sect,"emusic",emusic_volume);
6946 zc_set_config(sfx_sect,"pan",pan_style);
6947 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6948 }
6949 else
6950 {
6951 midi_volume = m;
6952 digi_volume = d;
6953 emusic_volume = e;
6954 zcmusic_bufsz = b;
6955 sfx_volume = s;
6956 pan_style = p;
6957 }
6958
6959 return D_O_K;
6960 }
6961
6962 int32_t queding(char const* s1, char const* s2, char const* s3)
6963 {
6964 return jwin_alert("ZQuest Classic",s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6965 }
6966
6967 int32_t onQuit()
6968 {
6969 if(Playing)
6970 {
6971 int32_t ret=0;
6972
6973 if(get_qr(qr_NOCONTINUE))
6974 {
6975 if(standalone_mode)
6976 {
6977 ret=queding("End current game?",
6978 "The continue screen is disabled; the game",
6979 "will be reloaded from the last save.");
6980 }
6981 else
6982 {
6983 ret=queding("End current game?",
6984 "The continue screen is disabled. You will",
6985 "be returned to the file select screen.");
6986 }
6987 }
6988 else
6989 ret=queding("End current game?",NULL,NULL);
6990
6991 if(ret==1)
6992 {
6993 disableClickToFreeze=false;
6994 Quit=qQUIT;
6995
6996 // Trying to evade a door repair charge?
6997 if(repaircharge)
6998 {
6999 game->change_drupy(-repaircharge);
7000 repaircharge=0;
7001 }
7002
7003 return D_CLOSE;
7004 }
7005 }
7006
7007 return D_O_K;
7008 }
7009
7010 int32_t onTryQuitMenu()
7011 {
7012 return onTryQuit(true);
7013 }
7014
7015 int32_t onTryQuit(bool inMenu)
7016 {
7017 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7018 {
7019 if(active_cutscene.can_f6())
7020 {
7021 if(get_qr(qr_OLD_F6))
7022 {
7023 if(inMenu) onQuit();
7024 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
7025 }
7026 else
7027 {
7028 disableClickToFreeze=false;
7029 GameFlags |= GAMEFLAG_TRYQUIT;
7030 }
7031 return D_CLOSE;
7032 }
7033 else active_cutscene.error();
7034 }
7035
7036 return D_O_K;
7037 }
7038
7039 int32_t onReset()
7040 {
7041 if(queding(" Reset system? ",NULL,NULL)==1)
7042 {
7043 disableClickToFreeze=false;
7044 Quit=qRESET;
7045 replay_quit();
7046 return D_CLOSE;
7047 }
7048
7049 return D_O_K;
7050 }
7051
7052 int32_t onExit()
7053 {
7054 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7055 {
7056 Quit=qEXIT;
7057 return D_CLOSE;
7058 }
7059
7060 return D_O_K;
7061 }
7062
7063 int32_t onDebug()
7064 {
7065 if(debug_enabled)
7066 set_debug(!get_debug());
7067 return D_O_K;
7068 }
7069
7070 int32_t onHeartBeep()
7071 {
7072 heart_beep=!heart_beep;
7073 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7074 return D_O_K;
7075 }
7076
7077 int32_t onSaveIndicator()
7078 {
7079 use_save_indicator = use_save_indicator ? 0 : 1;
7080 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7081 return D_O_K;
7082 }
7083
7084 int32_t onEpilepsy()
7085 {
7086 if(jwin_alert3(
7087 "Epilepsy Flash Reduction",
7088 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7089 "Disabling this will restore standard flash and wavy behaviour.",
7090 "Proceed?",
7091 "&Yes",
7092 "&No",
7093 NULL,
7094 'y',
7095 'n',
7096 0,
7097 get_zc_font(font_lfont)) == 1)
7098 {
7099 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7100 zc_set_config("zeldadx","checked_epilepsy",1);
7101 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7102 }
7103 return D_O_K;
7104 }
7105
7106 int32_t onTriforce()
7107 {
7108 for(int32_t i=0; i<MAXINITTABS; ++i)
7109 {
7110 init_tabs[i].flags&=~D_SELECTED;
7111 }
7112
7113 init_tabs[3].flags=D_SELECTED;
7114 return onCheatConsole();
7115 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7116 for(int32_t i=1; i<=8; i++)
7117 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7118
7119 if(do_zqdialog (triforce_dlg,-1)==9)
7120 {
7121 for(int32_t i=1; i<=8; i++)
7122 {
7123 game->lvlitems[i] &= ~liTRIFORCE;
7124 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7125 }
7126 }
7127 return D_O_K;*/
7128 }
7129
7130 bool rc = false;
7131 /*
7132 int32_t onEquipment()
7133 {
7134 for (int32_t i=0; i<MAXINITTABS; ++i)
7135 {
7136 init_tabs[i].flags&=~D_SELECTED;
7137 }
7138 init_tabs[0].flags=D_SELECTED;
7139 return onCheatConsole();
7140 }
7141 */
7142
7143 int32_t onItems()
7144 {
7145 for(int32_t i=0; i<MAXINITTABS; ++i)
7146 {
7147 init_tabs[i].flags&=~D_SELECTED;
7148 }
7149
7150 init_tabs[1].flags=D_SELECTED;
7151 return onCheatConsole();
7152 }
7153
7154 static DIALOG getnum_dlg[] =
7155 {
7156 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7157 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7158 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7159 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7160 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7161 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7162 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7163 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7164 };
7165
7166 int32_t getnumber(const char *prompt,int32_t initialval)
7167 {
7168 char buf[20];
7169 sprintf(buf,"%d",initialval);
7170 getnum_dlg[0].dp=(void *)prompt;
7171 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7172 getnum_dlg[2].dp=buf;
7173
7174 large_dialog(getnum_dlg);
7175
7176 if(do_zqdialog(getnum_dlg,2)==3)
7177 return atoi(buf);
7178
7179 return initialval;
7180 }
7181
7182 int32_t onLife()
7183 {
7184 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7185 cheats_enqueue(Cheat::Life, value);
7186 return D_O_K;
7187 }
7188
7189 int32_t onHeartC()
7190 {
7191 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7192 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7193 cheats_enqueue(Cheat::MaxLife, max_life);
7194 cheats_enqueue(Cheat::Life, life);
7195 return D_O_K;
7196 }
7197
7198 int32_t onMagicC()
7199 {
7200 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7201 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,max_magic/game->get_mp_per_block())*game->get_mp_per_block();
7202 cheats_enqueue(Cheat::MaxMagic, max_magic);
7203 cheats_enqueue(Cheat::Magic, magic);
7204 return D_O_K;
7205 }
7206
7207 int32_t onRupies()
7208 {
7209 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7210 cheats_enqueue(Cheat::Rupies, value);
7211 return D_O_K;
7212 }
7213
7214 int32_t onMaxBombs()
7215 {
7216 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7217 cheats_enqueue(Cheat::MaxBombs, value);
7218 cheats_enqueue(Cheat::Bombs, value);
7219 return D_O_K;
7220 }
7221
7222 int32_t onRefillLife()
7223 {
7224 cheats_enqueue(Cheat::Life, game->get_maxlife());
7225 return D_O_K;
7226 }
7227 int32_t onRefillMagic()
7228 {
7229 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7230 return D_O_K;
7231 }
7232 int32_t onClock()
7233 {
7234 cheats_enqueue(Cheat::Clock);
7235 return D_O_K;
7236 }
7237
7238 int32_t onQstPath()
7239 {
7240 char path[2048];
7241
7242 chop_path(qstdir);
7243 strcpy(path,qstdir);
7244
7245 go();
7246
7247 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7248 {
7249 chop_path(path);
7250 fix_filename_case(path);
7251 fix_filename_slashes(path);
7252 strcpy(qstdir,path);
7253 strcpy(qstpath,qstdir);
7254 zc_set_config("zeldadx","quest_dir",qstdir);
7255 flush_config_file();
7256 }
7257
7258 comeback();
7259 return D_O_K;
7260 }
7261
7262 #include "dialog/cheat_dialog.h"
7263 int32_t onCheat()
7264 {
7265 call_setcheat_dialog();
7266 game->set_cheat(maxcheat);
7267 if(cheat) game->did_cheat(true);
7268 return D_O_K;
7269 }
7270
7271 int32_t onCheatRupies()
7272 {
7273 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7274 return D_O_K;
7275 }
7276
7277 int32_t onCheatArrows()
7278 {
7279 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7280 return D_O_K;
7281 }
7282
7283 int32_t onCheatBombs()
7284 {
7285 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7286 return D_O_K;
7287 }
7288
7289 // *** screen saver
7290
7291 9285403 int32_t after_time()
7292 {
7293
1/2
✓ Branch 0 taken 9285403 times.
✗ Branch 1 not taken.
9285403 if(ss_enable == 0)
7294 return INT_MAX;
7295
7296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285403 times.
9285403 if(ss_after <= 0)
7297 return 5 * 60;
7298
7299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285403 times.
9285403 if(ss_after <= 3)
7300 return ss_after * 15 * 60;
7301
7302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285403 times.
9285403 if(ss_after <= 13)
7303 return (ss_after - 3) * 60 * 60;
7304
7305 9285403 return MAX_IDLE + 1;
7306 9285403 }
7307
7308 static const char *after_str[15] =
7309 {
7310 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7311 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7312 "Never"
7313 };
7314
7315 const char *after_list(int32_t index, int32_t *list_size)
7316 {
7317 if(index < 0)
7318 {
7319 *list_size = 15;
7320 return NULL;
7321 }
7322
7323 return after_str[index];
7324 }
7325
7326 114 static ListData after__list(after_list, &font);
7327
7328 static DIALOG scrsaver_dlg[] =
7329 {
7330 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7331 114 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7332 114 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7333 114 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7334 114 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7335 114 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7336 114 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7337 114 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7338 114 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7339 114 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7340 114 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7341 114 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7342 114 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7343 114 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7344 };
7345
7346 int32_t onScreenSaver()
7347 {
7348 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7349 int32_t oldcfgs[3];
7350 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7351 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7352 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7353
7354 large_dialog(scrsaver_dlg);
7355
7356 int32_t ret = do_zqdialog(scrsaver_dlg,-1);
7357
7358 if(ret == 8 || ret == 9)
7359 {
7360 ss_after = scrsaver_dlg[5].d1;
7361 ss_speed = scrsaver_dlg[6].d2;
7362 ss_density = scrsaver_dlg[7].d2;
7363 if(oldcfgs[0] != ss_after)
7364 zc_set_config(cfg_sect,"ss_after",ss_after);
7365 if(oldcfgs[1] != ss_speed)
7366 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7367 if(oldcfgs[2] != ss_density)
7368 zc_set_config(cfg_sect,"ss_density",ss_density);
7369 }
7370
7371 if(ret == 9)
7372 // preview Screen Saver
7373 {
7374 clear_keybuf();
7375 Matrix(ss_speed, ss_density, 30);
7376 system_pal(true);
7377 sys_mouse();
7378 }
7379
7380 return D_O_K;
7381 }
7382
7383 /***** Menus *****/
7384
7385 static MENU game_menu[] =
7386 {
7387 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7388 { (char *)"", NULL, NULL, 0, NULL },
7389 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7390 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7391 { (char *)"", NULL, NULL, 0, NULL },
7392 #ifdef __EMSCRIPTEN__
7393 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7394 #elif defined(ALLEGRO_MACOSX)
7395 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7396 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7397 #else
7398 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7399 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7400 #endif
7401 { NULL, NULL, NULL, 0, NULL }
7402 };
7403
7404 static MENU snapshot_format_menu[] =
7405 {
7406 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7407 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7408 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7409 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7410 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7411 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7412 { NULL, NULL, NULL, 0, NULL }
7413 };
7414
7415 static MENU controls_menu[] =
7416 {
7417 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7418 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7419 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7420 { NULL, NULL, NULL, 0, NULL }
7421 };
7422
7423 static MENU name_entry_mode_menu[] =
7424 {
7425 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7426 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7427 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7428 { NULL, NULL, NULL, 0, NULL }
7429 };
7430
7431 static void set_controls_menu_active()
7432 {
7433
7434 }
7435
7436 static MENU window_menu[] =
7437 {
7438 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7439 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7440 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7441 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7442 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7443 { NULL, NULL, NULL, 0, NULL }
7444 };
7445 static MENU options_menu[] =
7446 {
7447 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7448 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7449 { "&Window Settings", NULL, window_menu, 0, NULL },
7450 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7451 { "Pause In Background", onPauseInBackground, NULL, 0, NULL },
7452 { NULL, NULL, NULL, 0, NULL }
7453 };
7454 static MENU settings_menu[] =
7455 {
7456 { "&Sound...", onSound, NULL, 0, NULL },
7457 { "C&ontrols", NULL, controls_menu, 0, NULL },
7458 { "", NULL, NULL, 0, NULL },
7459 { "Options", NULL, options_menu, 0, NULL },
7460 { "", NULL, NULL, 0, NULL },
7461 //
7462 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7463 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7464 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7465 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7466 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7467 //
7468 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7469 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7470 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7471 { "", NULL, NULL, 0, NULL },
7472 { "Debu&g", onDebug, NULL, 0, NULL },
7473 //
7474 { NULL, NULL, NULL, 0, NULL }
7475 };
7476
7477
7478 static MENU misc_menu[] =
7479 {
7480 { (char *)"&About...", onAbout, NULL, 0, NULL },
7481 // TODO: re-enable, but: 1) do not use a bitmap thing that is hard to update 2) update names and 3) don't use the Z-word.
7482 { (char *)"&Credits...", onCredits, NULL, D_DISABLED, NULL },
7483 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7484 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7485 { (char *)"", NULL, NULL, 0, NULL },
7486 //5
7487 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7488 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7489 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7490 { (char *)"", NULL, NULL, 0, NULL },
7491 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7492 //10
7493 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7494 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7495 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7496 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7497 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7498 //15
7499 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7500 { NULL, NULL, NULL, 0, NULL }
7501 };
7502
7503 static MENU refill_menu[] =
7504 {
7505 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7506 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7507 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7508 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7509 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7510 { NULL, NULL, NULL, 0, NULL }
7511 };
7512
7513 static MENU show_menu[] =
7514 {
7515 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7516 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7517 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7518 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7519 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7520 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7521 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7522 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7523 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7524 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7525 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7526 { (char *)"", NULL, NULL, 0, NULL },
7527 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7528 { (char *)"", NULL, NULL, 0, NULL },
7529 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7530 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7531 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7532 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7533 { NULL, NULL, NULL, 0, NULL }
7534 };
7535
7536 static MENU cheat_menu[] =
7537 {
7538 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7539 { (char *)"", NULL, NULL, 0, NULL },
7540 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7541 { (char *)"", NULL, NULL, 0, NULL },
7542 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7543 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7544 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7545 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7546 { (char *)"", NULL, NULL, 0, NULL },
7547 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7548 { (char *)"", NULL, NULL, 0, NULL },
7549 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7550 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7551 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7552 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7553 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7554 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7555 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7556 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7557 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7558 { NULL, NULL, NULL, 0, NULL }
7559 };
7560
7561 #if DEVLEVEL > 0
7562 int32_t devLogging();
7563 int32_t devDebug();
7564 int32_t devTimestmp();
7565 #if DEVLEVEL > 1
7566 int32_t setCheat();
7567 #endif //DEVLEVEL > 1
7568 enum
7569 {
7570 dv_log,
7571 // dv_dbg,
7572 dv_tmpstmp,
7573 #if DEVLEVEL > 1
7574 dv_nil,
7575 dv_setcheat,
7576 #endif //DEVLEVEL > 1
7577 dv_max
7578 };
7579 static MENU dev_menu[] =
7580 {
7581 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7582 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7583 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7584 #if DEVLEVEL > 1
7585 { (char *)"", NULL, NULL, 0, NULL },
7586 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7587 #endif //DEVLEVEL > 1
7588 { NULL, NULL, NULL, 0, NULL }
7589 };
7590 int32_t devLogging()
7591 {
7592 dev_logging = !dev_logging;
7593 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7594 return D_O_K;
7595 }
7596 // int32_t devDebug()
7597 // {
7598 // dev_debug = !dev_debug;
7599 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7600 // return D_O_K;
7601 // }
7602 int32_t devTimestmp()
7603 {
7604 dev_timestmp = !dev_timestmp;
7605 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7606 return D_O_K;
7607 }
7608 #if DEVLEVEL > 1
7609 int32_t setCheat()
7610 {
7611 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7612 return D_O_K;
7613 }
7614 #endif //DEVLEVEL > 1
7615 #endif //DEVLEVEL > 0
7616
7617 MENU the_player_menu[] =
7618 {
7619 { (char *)"&Game", NULL, game_menu, 0, NULL },
7620 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7621 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7622 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7623 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7624 #if DEVLEVEL > 0
7625 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7626 #endif
7627 { NULL, NULL, NULL, 0, NULL }
7628 };
7629 int32_t onPauseInBackground()
7630 {
7631 if(jwin_alert3(
7632 "Toggle Pause In Background",
7633 "This action will change whether ZC Player pauses when the window loses focus.",
7634 "",
7635 "Proceed?",
7636 "&Yes",
7637 "&No",
7638 NULL,
7639 'y',
7640 'n',
7641 0,
7642 get_zc_font(font_lfont)) == 1)
7643 {
7644 pause_in_background = pause_in_background ? 0 : 1;
7645 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7646 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7647 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7648 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7649 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7650 }
7651 options_menu[4].flags =(pause_in_background)?D_SELECTED:0;
7652 return D_O_K;
7653 }
7654
7655 int32_t onKeyboardEntry()
7656 {
7657 NameEntryMode=0;
7658 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7659 return D_O_K;
7660 }
7661
7662 int32_t onLetterGridEntry()
7663 {
7664 NameEntryMode=1;
7665 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7666 return D_O_K;
7667 }
7668
7669 int32_t onExtLetterGridEntry()
7670 {
7671 NameEntryMode=2;
7672 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7673 return D_O_K;
7674 }
7675
7676 static BITMAP* oldscreen;
7677 int32_t onFullscreenMenu()
7678 {
7679 // super hacks
7680 screen = oldscreen;
7681 if (onFullscreen() == D_REDRAW)
7682 {
7683 oldscreen = screen;
7684 }
7685 screen = menu_bmp;
7686 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7687 return D_O_K;
7688 }
7689
7690 114 void fix_menu()
7691 {
7692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!debug_enabled)
7693 114 settings_menu[13].text = NULL;
7694 114 }
7695
7696 static DIALOG system_dlg[] =
7697 {
7698 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7699 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7700 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7701 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7702 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7703 #ifndef ALLEGRO_MACOSX
7704 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7705 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7706 #else
7707 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7708 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7709 #endif
7710 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7711 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7712 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7713 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7714 };
7715
7716 void reset_snapshot_format_menu()
7717 {
7718 for(int32_t i=0; i<ssfmtMAX; ++i)
7719 {
7720 snapshot_format_menu[i].flags=0;
7721 }
7722 }
7723
7724 int32_t onSetSnapshotFormat()
7725 {
7726 switch(active_menu->text[1])
7727 {
7728 case 'B': //"&BMP"
7729 SnapshotFormat=0;
7730 break;
7731
7732 case 'G': //"&GIF"
7733 SnapshotFormat=1;
7734 break;
7735
7736 case 'J': //"&JPG"
7737 SnapshotFormat=2;
7738 break;
7739
7740 case 'P': //"&PNG"
7741 SnapshotFormat=3;
7742 break;
7743
7744 case 'C': //"PC&X"
7745 SnapshotFormat=4;
7746 break;
7747
7748 case 'T': //"&TGA"
7749 SnapshotFormat=5;
7750 break;
7751
7752 case 'L': //"&LBM"
7753 SnapshotFormat=6;
7754 break;
7755 }
7756 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7757
7758 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7759 return D_O_K;
7760 }
7761
7762
7763 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7764 {
7765 PALETTE tmp;
7766
7767 for(int32_t i=0; i<256; i++)
7768 {
7769 tmp[i].r=r;
7770 tmp[i].g=g;
7771 tmp[i].b=b;
7772 }
7773
7774 fade_interpolate(src,tmp,dest,pos,from,to);
7775 }
7776
7777 14 void system_pal(bool force)
7778 {
7779
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 if(is_sys_pal && !force) return;
7780 14 is_sys_pal = true;
7781 14 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7782 14 hw_palette = &syspal;
7783 14 update_hw_pal = true;
7784 14 }
7785
7786 static uint32_t entered_sys_pal = 0;
7787 14 void enter_sys_pal()
7788 {
7789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
7790 {
7791 if(entered_sys_pal)
7792 ++entered_sys_pal;
7793 return;
7794 }
7795 14 sys_mouse();
7796 14 system_pal(true);
7797 14 ++entered_sys_pal;
7798 14 }
7799 14 void exit_sys_pal()
7800 {
7801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
7802 {
7803
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
7804 {
7805 14 game_pal();
7806 14 game_mouse();
7807 14 }
7808 14 }
7809 14 }
7810
7811 void switch_out_callback()
7812 {
7813 if (pause_in_background && !MenuOpen)
7814 {
7815 System();
7816 }
7817 }
7818
7819 void switch_in_callback()
7820 {
7821 }
7822
7823 420 void game_pal()
7824 {
7825 420 is_sys_pal = false;
7826 420 entered_sys_pal = 0;
7827 420 hw_palette = &RAMpal;
7828 420 update_hw_pal = true;
7829 420 }
7830
7831 static char bar_str[] = "";
7832
7833 14 void music_pause()
7834 {
7835 //al_pause_duh(tmplayer);
7836 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
7837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(zcmixer->oldtrack)
7838 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
7839 14 zc_midi_pause();
7840 14 }
7841
7842 void music_resume()
7843 {
7844 //al_resume_duh(tmplayer);
7845 zcmusic_pause(zcmusic, ZCM_RESUME);
7846 if (zcmixer->oldtrack)
7847 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
7848 zc_midi_resume();
7849 }
7850
7851 3357 void music_stop()
7852 {
7853 //al_stop_duh(tmplayer);
7854 //unload_duh(tmusic);
7855 //tmusic=NULL;
7856 //tmplayer=NULL;
7857 3357 zcmusic_stop(zcmusic);
7858 3357 zcmusic_unload_file(zcmusic);
7859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3357 times.
3357 if (zcmixer->oldtrack)
7860 {
7861 zcmusic_stop(zcmixer->oldtrack);
7862 zcmusic_unload_file(zcmixer->oldtrack);
7863 }
7864 3357 zcmixer->newtrack = NULL;
7865 3357 zc_stop_midi();
7866 3357 currmidi=-1;
7867 3357 }
7868
7869 void System()
7870 {
7871 mouse_down=gui_mouse_b();
7872 music_pause();
7873 pause_all_sfx();
7874 MenuOpen = true;
7875 enter_sys_pal();
7876 // FONT *oldfont=font;
7877 // font=tfont;
7878
7879 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7880 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7881
7882 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7883 #if DEVLEVEL > 1
7884 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7885 #endif
7886 game_menu[3].flags =
7887 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7888 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7889 clear_keybuf();
7890
7891 DIALOG_PLAYER *p;
7892
7893 clear_bitmap(menu_bmp);
7894 oldscreen = screen;
7895 screen = menu_bmp;
7896
7897 p = init_dialog(system_dlg,-1);
7898
7899 // drop the menu on startup if menu button pressed
7900 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7901 simulate_keypress(KEY_G << 8);
7902
7903 do
7904 {
7905 if(handle_close_btn_quit())
7906 break;
7907
7908 rest(17);
7909
7910 if(mouse_down && !gui_mouse_b())
7911 mouse_down=0;
7912
7913 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7914 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
7915 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
7916 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
7917 settings_menu[9].flags = TransLayers?D_SELECTED:0;
7918 settings_menu[10].flags = NESquit?D_SELECTED:0;
7919 settings_menu[11].flags = volkeys?D_SELECTED:0;
7920
7921 window_menu[0].flags = DragAspect?D_SELECTED:0;
7922 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
7923 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
7924 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
7925 window_menu[4].flags = stretchGame?D_SELECTED:0;
7926
7927 options_menu[3].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
7928 options_menu[4].flags = (pause_in_background)?D_SELECTED:0;
7929
7930 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
7931 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
7932 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
7933
7934 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
7935 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
7936 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
7937
7938 bool nocheat = (replay_is_replaying() || !Playing
7939 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7940 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
7941 cheat_menu[0].flags = 0;
7942 refill_menu[4].flags = get_qr(qr_TRUEARROWS) ? 0 : D_DISABLED;
7943 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
7944 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
7945 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
7946 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
7947 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
7948 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
7949 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
7950 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
7951
7952 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
7953 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
7954 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
7955 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
7956 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
7957 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
7958 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
7959 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
7960 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
7961 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
7962 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
7963 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
7964 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
7965 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
7966 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
7967
7968 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
7969 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
7970
7971 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
7972 (char *)"Disable recording new saves" :
7973 (char *)"Enable recording new saves";
7974 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
7975 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
7976 (char *)"Stop recording" :
7977 (char *)"Stop replaying";
7978 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
7979 replay_menu[6].text = replay_is_snapshot_all_frames() ?
7980 (char *)"Disable snapshot all frames" :
7981 (char *)"Enable snapshot all frames";
7982
7983 reset_snapshot_format_menu();
7984 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
7985
7986 if(debug_enabled)
7987 {
7988 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
7989 }
7990
7991 if(gui_mouse_b() && !mouse_down)
7992 break;
7993
7994 // press menu to drop the menu
7995 if(rMbtn())
7996 simulate_keypress(KEY_G << 8);
7997
7998 if(input_idle(true) > after_time())
7999 // run Screeen Saver
8000 {
8001 // Screen saver enabled for now.
8002 clear_keybuf();
8003 Matrix(ss_speed, ss_density, 0);
8004 system_pal(true);
8005 sys_mouse();
8006 broadcast_dialog_message(MSG_DRAW, 0);
8007 }
8008
8009 update_hw_screen();
8010 }
8011 while(update_dialog(p));
8012
8013 screen = oldscreen;
8014
8015 // font=oldfont;
8016 mouse_down=gui_mouse_b();
8017 shutdown_dialog(p);
8018 MenuOpen = false;
8019 if(Quit)
8020 {
8021 kill_sfx();
8022 music_stop();
8023 update_hw_screen();
8024 }
8025 else
8026 {
8027 music_resume();
8028 resume_all_sfx();
8029
8030 if(rc)
8031 ringcolor(false);
8032 }
8033 exit_sys_pal();
8034
8035 eat_buttons();
8036
8037 rc=false;
8038 clear_keybuf();
8039 // text_mode(0);
8040 }
8041
8042 114 void fix_dialogs()
8043 {
8044 114 jwin_center_dialog(about_dlg);
8045 114 jwin_center_dialog(gamepad_dlg);
8046 114 jwin_center_dialog(credits_dlg);
8047 114 jwin_center_dialog(gamemode_dlg);
8048 114 jwin_center_dialog(getnum_dlg);
8049 114 jwin_center_dialog(goto_dlg);
8050 114 jwin_center_dialog(keyboard_control_dlg);
8051 114 jwin_center_dialog(midi_dlg);
8052 114 jwin_center_dialog(quest_dlg);
8053 114 jwin_center_dialog(scrsaver_dlg);
8054 114 jwin_center_dialog(sound_dlg);
8055 114 jwin_center_dialog(triforce_dlg);
8056
8057 // digi_dp[1] += scrx;
8058 // digi_dp[2] += scry;
8059 // midi_dp[1] += scrx;
8060 // midi_dp[2] += scry;
8061 // pan_dp[1] += scrx;
8062 // pan_dp[2] += scry;
8063 // emus_dp[1] += scrx;
8064 // emus_dp[2] += scry;
8065 // buf_dp[1] += scrx;
8066 // buf_dp[2] += scry;
8067 // sfx_dp[1] += scrx;
8068 // sfx_dp[2] += scry;
8069 114 }
8070
8071 /*****************************/
8072 /**** Custom Sound System ****/
8073 /*****************************/
8074
8075 114 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8076 {
8077
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8078 }
8079
8080 // Run an NSF, or a MIDI if the NSF is missing somehow.
8081 149 bool try_zcmusic(const char *filename, int32_t track, int32_t midi, int32_t fadeoutframes)
8082 {
8083 149 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8084
8085 // Found it
8086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(newzcmusic!=NULL)
8087 {
8088 newzcmusic->fadevolume = 10000;
8089 newzcmusic->fadeoutframes = fadeoutframes;
8090
8091 zcmixer->newtrack = newzcmusic;
8092
8093 zcmusic_stop(zcmusic);
8094 zcmusic_unload_file(zcmusic);
8095 zc_stop_midi();
8096
8097 zcmusic=newzcmusic;
8098 int32_t temp_volume = emusic_volume;
8099 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8100 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
8101 temp_volume = (temp_volume * zcmusic->fadevolume) / 10000;
8102 zcmusic_play(zcmusic, temp_volume);
8103
8104 if(track>0)
8105 zcmusic_change_track(zcmusic,track);
8106
8107 return true;
8108 }
8109
8110 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8111
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 70 times.
149 else if(midi>-1000)
8112 70 jukebox(midi);
8113
8114 149 return false;
8115 149 }
8116
8117 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8118 {
8119 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8120 // Found it
8121 if(newzcmusic!=NULL)
8122 {
8123 zcmusic_stop(zcmusic);
8124 zcmusic_unload_file(zcmusic);
8125 zc_stop_midi();
8126
8127 zcmusic=newzcmusic;
8128 zcmusic_play(zcmusic, emusic_volume);
8129
8130 if(track>0)
8131 zcmusic_change_track(zcmusic,track);
8132
8133 return true;
8134 }
8135
8136 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8137 else if(midi>-1000)
8138 jukebox(midi);
8139
8140 return false;
8141 }
8142
8143 int32_t get_zcmusicpos()
8144 {
8145 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8146 return debugtracething;
8147 return 0;
8148 }
8149
8150 void set_zcmusicpos(int32_t position)
8151 {
8152 zcmusic_set_curpos(zcmusic, position);
8153 }
8154
8155 void set_zcmusicspeed(int32_t speed)
8156 {
8157 zcmusic_set_speed(zcmusic, speed);
8158 }
8159
8160 int32_t get_zcmusiclen()
8161 {
8162 return zcmusic_get_length(zcmusic);
8163 }
8164
8165 void set_zcmusicloop(double start, double end)
8166 {
8167 zcmusic_set_loop(zcmusic, start, end);
8168 }
8169
8170 63941 void jukebox(int32_t index,int32_t loop)
8171 {
8172
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if (is_headless())
8173 63941 return;
8174
8175 music_stop();
8176
8177 if(index<0) index=MAXMIDIS-1;
8178
8179 if(index>=MAXMIDIS) index=0;
8180
8181 music_stop();
8182
8183 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8184 // stuck notes when a song stops. This fixes it.
8185 if(strcmp(midi_driver->name, "DIGMID")==0)
8186 zc_set_volume(0, 0);
8187
8188 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
8189 zc_play_midi((MIDI*)tunes[index].data,loop);
8190
8191 if(tunes[index].start>0)
8192 zc_midi_seek(tunes[index].start);
8193
8194 midi_loop_start = tunes[index].loop_start;
8195 midi_loop_end = tunes[index].loop_end;
8196
8197 currmidi=index;
8198 master_volume(digi_volume, midi_volume);
8199 //midi_paused=false;
8200 63941 }
8201
8202 63941 void jukebox(int32_t index)
8203 {
8204
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index<0) index=MAXMIDIS-1;
8205
8206
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index>=MAXMIDIS) index=0;
8207
8208 // do nothing if it's already playing
8209
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63941 if(index==currmidi && midi_pos>=0)
8210 {
8211 return;
8212 }
8213
8214 63941 jukebox(index,tunes[index].loop);
8215 63941 }
8216
8217 16 void play_DmapMusic()
8218 {
8219
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (is_headless())
8220 16 return;
8221
8222 static char tfile[2048];
8223 static int32_t ttrack=0;
8224 bool domidi=false;
8225
8226 int32_t fadeoutframes = 0;
8227 if (zcmusic != NULL)
8228 fadeoutframes = zcmusic->fadeoutframes;
8229
8230 if(DMaps[currdmap].tmusic[0]!=0)
8231 {
8232 if(zcmusic==NULL ||
8233 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8234 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8235 {
8236 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
8237 {
8238 if (FFCore.play_enh_music_crossfade(DMaps[currdmap].tmusic, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
8239 {
8240 if (zcmusic != NULL)
8241 {
8242 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
8243 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8244 }
8245 }
8246 }
8247 else
8248 {
8249 if (zcmusic != NULL)
8250 {
8251 zcmusic_stop(zcmusic);
8252 zcmusic_unload_file(zcmusic);
8253 zcmusic = NULL;
8254 zcmixer->newtrack = NULL;
8255 }
8256
8257 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8258 zcmixer->newtrack = zcmusic;
8259
8260 if (zcmusic != NULL)
8261 {
8262 zc_stop_midi();
8263 strcpy(tfile, DMaps[currdmap].tmusic);
8264 zcmusic_play(zcmusic, emusic_volume);
8265 int32_t temptracks = 0;
8266 temptracks = zcmusic_get_tracks(zcmusic);
8267 temptracks = (temptracks < 2) ? 1 : temptracks;
8268 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8269 zcmusic_change_track(zcmusic, ttrack);
8270 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8271 }
8272 else
8273 {
8274 tfile[0] = 0;
8275 domidi = true;
8276 }
8277 }
8278 }
8279 }
8280 else
8281 {
8282 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8283 {
8284 FFCore.play_enh_music_crossfade(NULL, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8285 }
8286 else
8287 {
8288 domidi = true;
8289 }
8290 }
8291
8292 if(domidi)
8293 {
8294 int32_t m=DMaps[currdmap].midi;
8295
8296 switch(m)
8297 {
8298 case 1:
8299 jukebox(ZC_MIDI_OVERWORLD);
8300 break;
8301
8302 case 2:
8303 jukebox(ZC_MIDI_DUNGEON);
8304 break;
8305
8306 case 3:
8307 jukebox(ZC_MIDI_LEVEL9);
8308 break;
8309
8310 default:
8311 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8312 jukebox(m+MIDIOFFSET_DMAP);
8313 else
8314 music_stop();
8315 }
8316 }
8317 16 }
8318
8319 15751 void playLevelMusic()
8320 {
8321
1/2
✓ Branch 0 taken 15751 times.
✗ Branch 1 not taken.
15751 if (is_headless())
8322 15751 return;
8323
8324 int32_t m=tmpscr->screen_midi;
8325
8326 switch(m)
8327 {
8328 case -2:
8329 music_stop();
8330 break;
8331
8332 case -1:
8333 play_DmapMusic();
8334 break;
8335
8336 case 1:
8337 jukebox(ZC_MIDI_OVERWORLD);
8338 break;
8339
8340 case 2:
8341 jukebox(ZC_MIDI_DUNGEON);
8342 break;
8343
8344 case 3:
8345 jukebox(ZC_MIDI_LEVEL9);
8346 break;
8347
8348 default:
8349 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8350 jukebox(m+MIDIOFFSET_MAPSCR);
8351 else
8352 music_stop();
8353 }
8354 15751 }
8355
8356 114 void master_volume(int32_t dv,int32_t mv)
8357 {
8358
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114 times.
✗ Branch 7 not taken.
114 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8359
8360
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114 times.
✗ Branch 7 not taken.
114 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8361
8362
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 114 times.
114 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8363 114 int32_t temp_vol = midi_volume;
8364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8365 114 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8366 114 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8367 114 }
8368
8369 /*****************/
8370 /***** SFX *****/
8371 /*****************/
8372
8373 // array of voices, one for each sfx sample in the data file
8374 // 0+ = voice #
8375 // -1 = voice not allocated
8376 114 void Z_init_sound()
8377 {
8378
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<WAV_COUNT; i++)
8379 29184 sfx_voice[i]=-1;
8380
8381 114 const char* midis[ZC_MIDI_COUNT] = {
8382 "assets/dungeon.mid",
8383 "assets/ending.mid",
8384 "assets/gameover.mid",
8385 "assets/level9.mid",
8386 "assets/overworld.mid",
8387 "assets/title.mid",
8388 "assets/triforce.mid",
8389 };
8390
2/2
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 114 times.
912 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8391 {
8392 798 tunes[i].data = load_midi(midis[i]);
8393
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 if (!tunes[i].data)
8394 Z_error_fatal("Missing required file %s\n", midis[i]);
8395 798 }
8396
8397
2/2
✓ Branch 0 taken 28728 times.
✓ Branch 1 taken 114 times.
28842 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8398 28728 tunes[ZC_MIDI_COUNT+j].data=NULL;
8399
8400 114 master_volume(digi_volume,midi_volume);
8401 114 }
8402
8403 // returns number of voices currently allocated
8404 int32_t sfx_count()
8405 {
8406 int32_t c=0;
8407
8408 for(int32_t i=0; i<WAV_COUNT; i++)
8409 if(sfx_voice[i]!=-1)
8410 ++c;
8411
8412 return c;
8413 }
8414
8415 // clean up finished samples
8416 9216659 void sfx_cleanup()
8417 {
8418
2/2
✓ Branch 0 taken 2359464704 times.
✓ Branch 1 taken 9216659 times.
2368681363 for(int32_t i=0; i<WAV_COUNT; i++)
8419
3/4
✓ Branch 0 taken 619381 times.
✓ Branch 1 taken 2358845323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619381 times.
2360084085 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8420 {
8421 619381 deallocate_voice(sfx_voice[i]);
8422 619381 sfx_voice[i]=-1;
8423 619381 }
8424 9216659 }
8425
8426 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8427 // if a voice is already allocated (and/or playing), then it just returns true
8428 // Returns true: voice is allocated
8429 // false: unsuccessful
8430 963799 bool sfx_init(int32_t index)
8431 {
8432 // check index
8433
3/4
✓ Branch 0 taken 721410 times.
✓ Branch 1 taken 242389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721410 times.
963799 if(index<=0 || index>=WAV_COUNT)
8434 242389 return false;
8435
8436
2/2
✓ Branch 0 taken 102011 times.
✓ Branch 1 taken 619399 times.
721410 if(sfx_voice[index]==-1)
8437 {
8438
2/2
✓ Branch 0 taken 209876 times.
✓ Branch 1 taken 409523 times.
619399 if(sfxdat)
8439 {
8440
1/2
✓ Branch 0 taken 209876 times.
✗ Branch 1 not taken.
209876 if(index<Z35)
8441 {
8442 209876 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8443 209876 }
8444 else
8445 {
8446 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8447 }
8448 209876 }
8449 else
8450 {
8451 409523 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8452 }
8453
8454 619399 int32_t temp_volume = sfx_volume;
8455
2/4
✓ Branch 0 taken 619399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 619399 times.
✗ Branch 3 not taken.
619399 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8456 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8457 619399 voice_set_volume(sfx_voice[index], temp_volume);
8458 619399 }
8459
8460 721410 return sfx_voice[index] != -1;
8461 963799 }
8462
8463 int32_t sfx_get_default_freq(int32_t index)
8464 {
8465 if (sfxdat)
8466 {
8467 if (index < Z35)
8468 {
8469 return ((SAMPLE*)sfxdata[index].dat)->freq;
8470 }
8471 else
8472 {
8473 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8474 }
8475 }
8476 else
8477 {
8478 return customsfxdata[index].freq;
8479 }
8480 }
8481
8482 int32_t sfx_get_length(int32_t index)
8483 {
8484 if (sfxdat)
8485 {
8486 if (index < Z35)
8487 {
8488 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8489 }
8490 else
8491 {
8492 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8493 }
8494 }
8495 else
8496 {
8497 return int32_t(customsfxdata[index].len);
8498 }
8499 }
8500
8501 // plays an sfx sample
8502 963799 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8503 {
8504
2/2
✓ Branch 0 taken 721410 times.
✓ Branch 1 taken 242389 times.
963799 if(!sfx_init(index))
8505 242389 return;
8506
1/2
✓ Branch 0 taken 721410 times.
✗ Branch 1 not taken.
721410 if (!is_headless())
8507 {
8508 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8509 voice_set_pan(sfx_voice[index], pan);
8510
8511 // Only used by ZScript currently
8512 if (freq <= -1)
8513 {
8514 freq = sfx_get_default_freq(index);
8515 }
8516 voice_set_frequency(sfx_voice[index], freq);
8517
8518 // Only used by ZScript currently
8519 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8520 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8521 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8522 voice_set_volume(sfx_voice[index], temp_volume);
8523
8524 int32_t pos = voice_get_position(sfx_voice[index]);
8525
8526 if (restart) voice_set_position(sfx_voice[index], 0);
8527
8528 if (pos <= 0)
8529 voice_start(sfx_voice[index]);
8530 }
8531
8532
3/4
✓ Branch 0 taken 397878 times.
✓ Branch 1 taken 323532 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 397878 times.
721410 if (restart && replay_is_debug())
8533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 397878 times.
397878 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8534 963799 }
8535
8536 // true if sfx is allocated
8537 68051 bool sfx_allocated(int32_t index)
8538 {
8539
3/4
✓ Branch 0 taken 9922 times.
✓ Branch 1 taken 58129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9922 times.
68051 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8540 }
8541
8542 // start it (in loop mode) if it's not already playing,
8543 // otherwise adjust it to play in loop mode -DD
8544 178220 void cont_sfx(int32_t index)
8545 {
8546
1/2
✓ Branch 0 taken 178220 times.
✗ Branch 1 not taken.
178220 if (is_headless())
8547 178220 return;
8548
8549 if(!sfx_init(index))
8550 {
8551 return;
8552 }
8553
8554 if(voice_get_position(sfx_voice[index])<=0)
8555 {
8556 voice_set_position(sfx_voice[index],0);
8557 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8558 voice_start(sfx_voice[index]);
8559 }
8560 else
8561 {
8562 adjust_sfx(index, 128, true);
8563 }
8564 178220 }
8565
8566 // adjust parameters while playing
8567 4075 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8568 {
8569
4/6
✓ Branch 0 taken 2315 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2315 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2315 times.
4075 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8570 4075 return;
8571
8572 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8573 voice_set_pan(sfx_voice[index],pan);
8574 4075 }
8575
8576 // pauses a voice
8577 1725 void pause_sfx(int32_t index)
8578 {
8579
3/6
✓ Branch 0 taken 1725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1725 times.
1725 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8580 voice_stop(sfx_voice[index]);
8581 1725 }
8582
8583 // resumes a voice
8584 747 void resume_sfx(int32_t index)
8585 {
8586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 if (is_headless())
8587 747 return;
8588
8589 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8590 voice_start(sfx_voice[index]);
8591 747 }
8592
8593 // pauses all active voices
8594 448 void pause_all_sfx()
8595 {
8596
2/2
✓ Branch 0 taken 114688 times.
✓ Branch 1 taken 448 times.
115136 for(int32_t i=0; i<WAV_COUNT; i++)
8597
2/2
✓ Branch 0 taken 114687 times.
✓ Branch 1 taken 1 times.
114689 if(sfx_voice[i]!=-1)
8598 1 voice_stop(sfx_voice[i]);
8599 448 }
8600
8601 // resumes all paused voices
8602 434 void resume_all_sfx()
8603 {
8604
2/2
✓ Branch 0 taken 111104 times.
✓ Branch 1 taken 434 times.
111538 for(int32_t i=0; i<WAV_COUNT; i++)
8605
1/2
✓ Branch 0 taken 111104 times.
✗ Branch 1 not taken.
111104 if(sfx_voice[i]!=-1)
8606 voice_start(sfx_voice[i]);
8607 434 }
8608
8609 // stops an sfx and deallocates the voice
8610 7338472 void stop_sfx(int32_t index)
8611 {
8612
3/4
✓ Branch 0 taken 6189921 times.
✓ Branch 1 taken 1148551 times.
✓ Branch 2 taken 6189921 times.
✗ Branch 3 not taken.
7338472 if(index<=0 || index>=WAV_COUNT)
8613 1148551 return;
8614
8615
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6189909 times.
6189921 if(sfx_voice[index]!=-1)
8616 {
8617 12 deallocate_voice(sfx_voice[index]);
8618 12 sfx_voice[index]=-1;
8619 12 }
8620 7338472 }
8621
8622 // Stops SFX played by Hero's item of the given family
8623 128638 void stop_item_sfx(int32_t family)
8624 {
8625 128638 int32_t id=current_item_id(family);
8626
8627
2/2
✓ Branch 0 taken 128083 times.
✓ Branch 1 taken 555 times.
128638 if(id<0)
8628 128083 return;
8629
8630 555 stop_sfx(itemsbuf[id].usesound);
8631 128638 }
8632
8633 3219 void kill_sfx()
8634 {
8635
2/2
✓ Branch 0 taken 824064 times.
✓ Branch 1 taken 3219 times.
827283 for(int32_t i=0; i<WAV_COUNT; i++)
8636
2/2
✓ Branch 0 taken 824058 times.
✓ Branch 1 taken 6 times.
824070 if(sfx_voice[i]!=-1)
8637 {
8638 6 deallocate_voice(sfx_voice[i]);
8639 6 sfx_voice[i]=-1;
8640 6 }
8641 3219 }
8642
8643 659526 int32_t pan(int32_t x)
8644 {
8645
1/4
✓ Branch 0 taken 659526 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
659526 switch(pan_style)
8646 {
8647 case 0:
8648 return 128;
8649
8650 case 1:
8651 659526 return vbound((x>>1)+68,0,255);
8652
8653 case 2:
8654 return vbound(((x*3)>>2)+36,0,255);
8655 }
8656
8657 return vbound(x,0,255);
8658 659526 }
8659
8660 /*******************************/
8661 /******* Input Handlers ********/
8662 /*******************************/
8663
8664 25088778 bool joybtn(int32_t b)
8665 {
8666
1/2
✓ Branch 0 taken 25088778 times.
✗ Branch 1 not taken.
25088778 if(b == 0)
8667 return false;
8668
1/2
✓ Branch 0 taken 25088778 times.
✗ Branch 1 not taken.
25088778 if (b-1 >= joy[joystick_index].num_buttons)
8669 25088778 return false;
8670
8671 return joy[joystick_index].button[b-1].b !=0;
8672 25088778 }
8673
8674 bool joystick(int32_t s)
8675 {
8676 if(s < 0)
8677 return false;
8678 if (s >= joy[joystick_index].num_sticks)
8679 return false;
8680
8681 for (int i = 0; i < joy[joystick_index].stick[s].num_axis; i++)
8682 {
8683 if (joy[joystick_index].stick[s].axis[i].d1 || joy[joystick_index].stick[s].axis[i].d2)
8684 return true;
8685 }
8686 return false;
8687 }
8688
8689 const char* joybtn_name(int32_t b)
8690 {
8691 if (b <= 0 || b > joy[joystick_index].num_buttons)
8692 return "";
8693
8694 return joy[joystick_index].button[b-1].name;
8695 }
8696
8697 const char* joystick_name(int32_t s)
8698 {
8699 if (s < 0 || s >= joy[joystick_index].num_sticks)
8700 return "";
8701
8702 return joy[joystick_index].stick[s].name;
8703 }
8704
8705 int32_t next_press_key();
8706
8707 int32_t next_joy_input(bool buttons)
8708 {
8709 clear_keybuf();
8710
8711 //first, we need to wait until they're pressing no buttons
8712 for(;;)
8713 {
8714 if(keypressed())
8715 {
8716 switch(readkey()>>8)
8717 {
8718 case KEY_ESC:
8719 return -1;
8720
8721 case KEY_SPACE:
8722 return 0;
8723 }
8724 }
8725
8726 poll_joystick();
8727 bool done = true;
8728
8729 if (buttons)
8730 {
8731 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8732 {
8733 if(joybtn(i)) done = false;
8734 }
8735 }
8736 else
8737 {
8738 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8739 {
8740 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8741 return -2;
8742 }
8743 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8744 {
8745 if(joystick(i)) done = false;
8746 }
8747 }
8748
8749 if(done) break;
8750 rest(1);
8751 }
8752
8753 //now, we need to wait for them to press any button
8754 for(;;)
8755 {
8756 if(keypressed())
8757 {
8758 switch(readkey()>>8)
8759 {
8760 case KEY_ESC:
8761 return -1;
8762
8763 case KEY_SPACE:
8764 return 0;
8765 }
8766 }
8767
8768 poll_joystick();
8769
8770 if (buttons)
8771 {
8772 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8773 {
8774 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8775 return -2;
8776 }
8777 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8778 {
8779 if(joybtn(i))
8780 return i;
8781 }
8782 }
8783 else
8784 {
8785 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8786 {
8787 if(joystick(i))
8788 return i;
8789 }
8790 }
8791 rest(1);
8792 }
8793 }
8794
8795 1204919 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8796 {
8797
2/2
✓ Branch 0 taken 1200568 times.
✓ Branch 1 taken 4351 times.
1204919 bool ret = btn && !flag;
8798 1204919 flag = rawbtn;
8799
8800 1204919 return ret;
8801 }
8802 190773566 static bool rButton(bool &btn, bool &flag)
8803 {
8804
2/2
✓ Branch 0 taken 183931037 times.
✓ Branch 1 taken 6842529 times.
190773566 bool ret = btn && !flag;
8805 190773566 flag = btn;
8806
8807 190773566 return ret;
8808 }
8809 2888422 static bool rButtonPeek(bool btn, bool flag)
8810 {
8811
2/2
✓ Branch 0 taken 2685421 times.
✓ Branch 1 taken 203001 times.
2888422 if(!btn)
8812 {
8813 2685421 return false;
8814 }
8815
2/2
✓ Branch 0 taken 17917 times.
✓ Branch 1 taken 185084 times.
203001 else if(!flag)
8816 {
8817 17917 return true;
8818 }
8819
8820 185084 return false;
8821 2888422 }
8822
8823 // Updated only by keyboard/gamepad.
8824 // If in replay mode, this is set directly by the replay system.
8825 // This should never be read from directly - use control_state instead.
8826 bool raw_control_state[ZC_CONTROL_STATES];
8827
8828 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8829 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8830 // lasts until the next call to load_control_state.
8831 bool control_state[ZC_CONTROL_STATES];
8832 bool disable_control[ZC_CONTROL_STATES];
8833 bool drunk_toggle_state[11];
8834 bool disabledKeys[127];
8835 bool KeyInput[127];
8836 bool KeyPress[127];
8837
8838 bool key_current_frame[127];
8839 bool key_previous_frame[127];
8840
8841 static bool key_system[127];
8842 static bool key_system_previous[127];
8843 static bool key_system_press[127];
8844
8845 bool button_press[ZC_CONTROL_STATES];
8846 bool button_hold[ZC_CONTROL_STATES];
8847
8848 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8849 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8850 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8851 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8852 #define STICK_PRECISION 56 //define your own sensitivity
8853
8854 7799627 void load_control_state()
8855 {
8856 7799627 load_control_called_this_frame = true;
8857
8858
2/2
✓ Branch 0 taken 4833196 times.
✓ Branch 1 taken 2966431 times.
7799627 if (replay_version_check(8, 11))
8859 {
8860
2/2
✓ Branch 0 taken 53395758 times.
✓ Branch 1 taken 2966431 times.
56362189 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8861 53395758 down_control_states[i] = raw_control_state[i];
8862 2966431 }
8863
8864
1/2
✓ Branch 0 taken 7799627 times.
✗ Branch 1 not taken.
7799627 if (!replay_is_replaying())
8865 {
8866 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8867 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8868 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8869 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8870 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8871 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8872 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8873 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8874 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8875 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8876 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8877 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8878 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8879 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8880
8881 if(num_joysticks != 0)
8882 {
8883 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8884 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8885 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8886 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8887 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8888 }
8889 else
8890 {
8891 raw_control_state[14] = false;
8892 raw_control_state[15] = false;
8893 raw_control_state[16] = false;
8894 raw_control_state[17] = false;
8895 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8896 }
8897 }
8898
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7799624 times.
7799627 if (replay_is_active())
8899 {
8900
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 6784409 times.
7799624 if (replay_get_version() < 3)
8901 1015215 replay_poll();
8902
3/4
✓ Branch 0 taken 6784409 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5023034 times.
✓ Branch 3 taken 1761375 times.
6784409 else if (replay_is_replaying() && replay_get_version() < 6)
8903 1761375 replay_peek_input();
8904
3/4
✓ Branch 0 taken 5023034 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2056603 times.
✓ Branch 3 taken 2966431 times.
5023034 else if (replay_is_replaying() && replay_version_check(8, 11))
8905 2966431 replay_peek_input();
8906
2/2
✓ Branch 0 taken 6696313 times.
✓ Branch 1 taken 1103311 times.
7799624 if (replay_get_version() == 8)
8907 1103311 update_keys();
8908 7799624 }
8909
8910 // Some test replay files were made before a serious input bug was fixed, so instead
8911 // of re-doing them or tossing them out, just check for that zplay version.
8912
3/4
✓ Branch 0 taken 7799621 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 7677721 times.
7799627 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8913
2/2
✓ Branch 0 taken 140393178 times.
✓ Branch 1 taken 7799621 times.
148192799 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8914 {
8915 140393178 control_state[i] = raw_control_state[i];
8916
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 90905868 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
140393178 if (botched_input && !control_state[i])
8917 47077142 down_control_states[i] = false;
8918 140393178 }
8919 7799621 bool did_bad_cutscene_btn = false;
8920
2/2
✓ Branch 0 taken 7799621 times.
✓ Branch 1 taken 140393178 times.
148192799 for(int q = 0; q < 18; ++q)
8921
4/4
✓ Branch 0 taken 6463221 times.
✓ Branch 1 taken 133929957 times.
✓ Branch 2 taken 6462487 times.
✓ Branch 3 taken 734 times.
140393912 if(control_state[q] && !active_cutscene.can_button(q))
8922 {
8923 734 control_state[q] = false;
8924 734 did_bad_cutscene_btn = true;
8925 734 }
8926
2/2
✓ Branch 0 taken 7799106 times.
✓ Branch 1 taken 515 times.
7799621 if(did_bad_cutscene_btn)
8927 515 active_cutscene.error();
8928
8929 7799621 button_press[0]=rButton(control_state[0],button_hold[0]);
8930 7799621 button_press[1]=rButton(control_state[1],button_hold[1]);
8931 7799621 button_press[2]=rButton(control_state[2],button_hold[2]);
8932 7799621 button_press[3]=rButton(control_state[3],button_hold[3]);
8933 7799621 button_press[4]=rButton(control_state[4],button_hold[4]);
8934 7799621 button_press[5]=rButton(control_state[5],button_hold[5]);
8935 7799621 button_press[6]=rButton(control_state[6],button_hold[6]);
8936 7799621 button_press[7]=rButton(control_state[7],button_hold[7]);
8937 7799621 button_press[8]=rButton(control_state[8],button_hold[8]);
8938 7799621 button_press[9]=rButton(control_state[9],button_hold[9]);
8939 7799621 button_press[10]=rButton(control_state[10],button_hold[10]);
8940 7799621 button_press[11]=rButton(control_state[11],button_hold[11]);
8941 7799621 button_press[12]=rButton(control_state[12],button_hold[12]);
8942 7799621 button_press[13]=rButton(control_state[13],button_hold[13]);
8943 7799621 button_press[14]=rButton(control_state[14],button_hold[14]);
8944 7799621 button_press[15]=rButton(control_state[15],button_hold[15]);
8945 7799621 button_press[16]=rButton(control_state[16],button_hold[16]);
8946 7799621 button_press[17]=rButton(control_state[17],button_hold[17]);
8947 7799621 }
8948
8949 // Returns true if any game key is pressed. This is needed because keypressed()
8950 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8951 40242783 bool zc_key_pressed()
8952 //may also need to use zc_getrawkey
8953 {
8954
7/10
✓ Branch 0 taken 32591359 times.
✓ Branch 1 taken 7651424 times.
✓ Branch 2 taken 7651424 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7651424 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6395143 times.
✓ Branch 7 taken 6395143 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2461236 times.
42704019 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8955
4/6
✓ Branch 0 taken 6395143 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6395143 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4843195 times.
✓ Branch 5 taken 4843195 times.
6395143 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8956
4/6
✓ Branch 0 taken 4843195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4843195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3142589 times.
✓ Branch 5 taken 3142589 times.
4843195 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8957
4/6
✓ Branch 0 taken 3142589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3142589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2731742 times.
✓ Branch 5 taken 2731742 times.
3142589 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8958
1/2
✓ Branch 0 taken 2731742 times.
✗ Branch 1 not taken.
2731742 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8959
3/4
✓ Branch 0 taken 2612335 times.
✓ Branch 1 taken 119407 times.
✓ Branch 2 taken 2612335 times.
✗ Branch 3 not taken.
2731742 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8960
3/4
✓ Branch 0 taken 2493446 times.
✓ Branch 1 taken 118889 times.
✓ Branch 2 taken 2493446 times.
✗ Branch 3 not taken.
2612335 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8961
3/4
✓ Branch 0 taken 2478301 times.
✓ Branch 1 taken 15145 times.
✓ Branch 2 taken 2478301 times.
✗ Branch 3 not taken.
2493446 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8962
3/4
✓ Branch 0 taken 2464802 times.
✓ Branch 1 taken 13499 times.
✓ Branch 2 taken 2464802 times.
✗ Branch 3 not taken.
2478301 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8963
3/4
✓ Branch 0 taken 2462312 times.
✓ Branch 1 taken 2490 times.
✓ Branch 2 taken 2462312 times.
✗ Branch 3 not taken.
2464802 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8964
3/4
✓ Branch 0 taken 2462094 times.
✓ Branch 1 taken 218 times.
✓ Branch 2 taken 2462094 times.
✗ Branch 3 not taken.
2462312 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8965
3/4
✓ Branch 0 taken 2461255 times.
✓ Branch 1 taken 839 times.
✓ Branch 2 taken 2461255 times.
✗ Branch 3 not taken.
2462094 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8966
2/4
✓ Branch 0 taken 2461255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461255 times.
✗ Branch 3 not taken.
2461255 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8967
2/2
✓ Branch 0 taken 2461236 times.
✓ Branch 1 taken 19 times.
2461255 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8968 72006885 return true;
8969
8970 2461236 return false;
8971 9285403 }
8972
8973 149972725 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8974 {
8975 149972725 bool ret = false, drunkstate = false, rawret = false;;
8976 149972725 bool* flag = &down_control_states[btn];
8977
2/7
✓ Branch 0 taken 140677985 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9294740 times.
149972725 switch(btn)
8978 {
8979 case btnF12:
8980 ret = zc_getkey(KEY_F12, ignoreDisable);
8981 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8982 eatEntirely = false;
8983 break;
8984 case btnF11:
8985 ret = zc_getkey(KEY_F11, ignoreDisable);
8986 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8987 eatEntirely = false;
8988 break;
8989 case btnF5:
8990 ret = zc_getkey(KEY_F5, ignoreDisable);
8991 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8992 eatEntirely = false;
8993 break;
8994 case btnQ:
8995 ret = zc_getkey(KEY_Q, ignoreDisable);
8996 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8997 eatEntirely = false;
8998 break;
8999 case btnI:
9000 ret = zc_getkey(KEY_I, ignoreDisable);
9001 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9002 eatEntirely = false;
9003 break;
9004 case btnM:
9005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9294740 times.
9294740 if(FFCore.kb_typing_mode) return false;
9006 9294740 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9007 9294740 eatEntirely = false;
9008 9294740 break;
9009 default: //control_state[] index
9010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140677985 times.
140677985 if(FFCore.kb_typing_mode) return false;
9011
5/6
✓ Branch 0 taken 139878206 times.
✓ Branch 1 taken 799779 times.
✓ Branch 2 taken 2214568 times.
✓ Branch 3 taken 137663638 times.
✓ Branch 4 taken 2214568 times.
✗ Branch 5 not taken.
140677985 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9012
2/2
✓ Branch 0 taken 8034116 times.
✓ Branch 1 taken 132643869 times.
140677985 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9013
4/4
✓ Branch 0 taken 126540917 times.
✓ Branch 1 taken 14137068 times.
✓ Branch 2 taken 3004 times.
✓ Branch 3 taken 14134064 times.
154815053 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9014 140677985 rawret = raw_control_state[btn];
9015 140677985 }
9016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149972725 times.
149972725 assert(flag);
9017
2/2
✓ Branch 0 taken 95498996 times.
✓ Branch 1 taken 54473729 times.
149972725 if(press)
9018 {
9019
2/2
✓ Branch 0 taken 2888422 times.
✓ Branch 1 taken 51585307 times.
54473729 if(peek)
9020 2888422 ret = rButtonPeek(ret, *flag);
9021
2/2
✓ Branch 0 taken 50380388 times.
✓ Branch 1 taken 1204919 times.
51585307 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
9022 1204919 else ret = rButton(ret, *flag, rawret);
9023 54473729 }
9024
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 149972725 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
149972725 if(eatEntirely && ret) control_state[btn] = false;
9025
3/4
✓ Branch 0 taken 112358793 times.
✓ Branch 1 taken 37613932 times.
✓ Branch 2 taken 112358793 times.
✗ Branch 3 not taken.
149972725 if(drunk && drunkstate) ret = !ret;
9026 149972725 return ret;
9027 149972725 }
9028
9029 7464162 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9030 {
9031 7464162 byte ret = 0;
9032
2/2
✓ Branch 0 taken 5485405 times.
✓ Branch 1 taken 1978757 times.
7464162 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9033
2/2
✓ Branch 0 taken 7333348 times.
✓ Branch 1 taken 130814 times.
7464162 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9034
2/2
✓ Branch 0 taken 7333473 times.
✓ Branch 1 taken 130689 times.
7464162 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9035
2/2
✓ Branch 0 taken 7333473 times.
✓ Branch 1 taken 130689 times.
7464162 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9036
2/2
✓ Branch 0 taken 7333473 times.
✓ Branch 1 taken 130689 times.
7464162 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9037
2/2
✓ Branch 0 taken 7333473 times.
✓ Branch 1 taken 130689 times.
7464162 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9038
2/2
✓ Branch 0 taken 7333473 times.
✓ Branch 1 taken 130689 times.
7464162 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9039
2/2
✓ Branch 0 taken 7333473 times.
✓ Branch 1 taken 130689 times.
7464162 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9040 7464162 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9041 }
9042
9043 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9044 {
9045 1114 return intbtn&vals;
9046 }
9047
9048 1767317 bool Up()
9049 {
9050 1767317 return getInput(btnUp);
9051 }
9052 147122 bool Down()
9053 {
9054 147122 return getInput(btnDown);
9055 }
9056 257424 bool Left()
9057 {
9058 257424 return getInput(btnLeft);
9059 }
9060 286629 bool Right()
9061 {
9062 286629 return getInput(btnRight);
9063 }
9064 164850 bool cAbtn()
9065 {
9066 164850 return getInput(btnA);
9067 }
9068 1411781 bool cBbtn()
9069 {
9070 1411781 return getInput(btnB);
9071 }
9072 bool cSbtn()
9073 {
9074 return getInput(btnS);
9075 }
9076 68744 bool cLbtn()
9077 {
9078 68744 return getInput(btnL);
9079 }
9080 68744 bool cRbtn()
9081 {
9082 68744 return getInput(btnR);
9083 }
9084 bool cPbtn()
9085 {
9086 return getInput(btnP);
9087 }
9088 bool cEx1btn()
9089 {
9090 return getInput(btnEx1);
9091 }
9092 bool cEx2btn()
9093 {
9094 return getInput(btnEx2);
9095 }
9096 bool cEx3btn()
9097 {
9098 return getInput(btnEx3);
9099 }
9100 bool cEx4btn()
9101 {
9102 return getInput(btnEx4);
9103 }
9104 bool AxisUp()
9105 {
9106 return getInput(btnAxisUp);
9107 }
9108 bool AxisDown()
9109 {
9110 return getInput(btnAxisDown);
9111 }
9112 bool AxisLeft()
9113 {
9114 return getInput(btnAxisLeft);
9115 }
9116 bool AxisRight()
9117 {
9118 return getInput(btnAxisRight);
9119 }
9120
9121 bool cMbtn()
9122 {
9123 return getInput(btnM);
9124 }
9125 bool cF12()
9126 {
9127 return getInput(btnF12);
9128 }
9129 bool cF11()
9130 {
9131 return getInput(btnF11);
9132 }
9133 bool cF5()
9134 {
9135 return getInput(btnF5);
9136 }
9137 bool cQ()
9138 {
9139 return getInput(btnQ);
9140 }
9141 bool cI()
9142 {
9143 return getInput(btnI);
9144 }
9145
9146 130270 bool rUp()
9147 {
9148 130270 return getInput(btnUp, true);
9149 }
9150 130174 bool rDown()
9151 {
9152 130174 return getInput(btnDown, true);
9153 }
9154 130122 bool rLeft()
9155 {
9156 130122 return getInput(btnLeft, true);
9157 }
9158 129657 bool rRight()
9159 {
9160 129657 return getInput(btnRight, true);
9161 }
9162 1295 bool rAbtn()
9163 {
9164 1295 return getInput(btnA, true);
9165 }
9166 1295 bool rBbtn()
9167 {
9168 1295 return getInput(btnB, true);
9169 }
9170 7395976 bool rSbtn()
9171 {
9172 7395976 return getInput(btnS, true);
9173 }
9174 9285403 bool rMbtn()
9175 {
9176 9285403 return getInput(btnM, true);
9177 }
9178 129441 bool rLbtn()
9179 {
9180 129441 return getInput(btnL, true);
9181 }
9182 129436 bool rRbtn()
9183 {
9184 129436 return getInput(btnR, true);
9185 }
9186 7332440 bool rPbtn()
9187 {
9188 7332440 return getInput(btnP, true);
9189 }
9190 bool rEx1btn()
9191 {
9192 return getInput(btnEx1, true);
9193 }
9194 bool rEx2btn()
9195 {
9196 return getInput(btnEx2, true);
9197 }
9198 139523 bool rEx3btn()
9199 {
9200 139523 return getInput(btnEx3, true);
9201 }
9202 139523 bool rEx4btn()
9203 {
9204 139523 return getInput(btnEx4, true);
9205 }
9206 bool rAxisUp()
9207 {
9208 return getInput(btnAxisUp, true);
9209 }
9210 bool rAxisDown()
9211 {
9212 return getInput(btnAxisDown, true);
9213 }
9214 bool rAxisLeft()
9215 {
9216 return getInput(btnAxisLeft, true);
9217 }
9218 bool rAxisRight()
9219 {
9220 return getInput(btnAxisRight, true);
9221 }
9222
9223 bool rF11()
9224 {
9225 return getInput(btnF11, true);
9226 }
9227 bool rQ()
9228 {
9229 return getInput(btnQ, true);
9230 }
9231 bool rI()
9232 {
9233 return getInput(btnI, true);
9234 }
9235
9236 18224319 bool DrunkUp()
9237 {
9238 18224319 return getInput(btnUp, false, true);
9239 }
9240 16887480 bool DrunkDown()
9241 {
9242 16887480 return getInput(btnDown, false, true);
9243 }
9244 10287620 bool DrunkLeft()
9245 {
9246 10287620 return getInput(btnLeft, false, true);
9247 }
9248 8833626 bool DrunkRight()
9249 {
9250 8833626 return getInput(btnRight, false, true);
9251 }
9252 8034732 bool DrunkcAbtn()
9253 {
9254 8034732 return getInput(btnA, false, true);
9255 }
9256 8016334 bool DrunkcBbtn()
9257 {
9258 8016334 return getInput(btnB, false, true);
9259 }
9260 7263310 bool DrunkcEx1btn()
9261 {
9262 7263310 return getInput(btnEx1, false, true);
9263 }
9264 7263330 bool DrunkcEx2btn()
9265 {
9266 7263330 return getInput(btnEx2, false, true);
9267 }
9268 bool DrunkcSbtn()
9269 {
9270 return getInput(btnS, false, true);
9271 }
9272 bool DrunkcMbtn()
9273 {
9274 return getInput(btnM, false, true);
9275 }
9276 bool DrunkcLbtn()
9277 {
9278 return getInput(btnL, false, true);
9279 }
9280 bool DrunkcRbtn()
9281 {
9282 return getInput(btnR, false, true);
9283 }
9284 bool DrunkcPbtn()
9285 {
9286 return getInput(btnP, false, true);
9287 }
9288
9289 bool DrunkrUp()
9290 {
9291 return getInput(btnUp, true, true);
9292 }
9293 bool DrunkrDown()
9294 {
9295 return getInput(btnDown, true, true);
9296 }
9297 bool DrunkrLeft()
9298 {
9299 return getInput(btnLeft, true, true);
9300 }
9301 bool DrunkrRight()
9302 {
9303 return getInput(btnRight, true, true);
9304 }
9305 6081182 bool DrunkrAbtn()
9306 {
9307 6081182 return getInput(btnA, true, true);
9308 }
9309 6098003 bool DrunkrBbtn()
9310 {
9311 6098003 return getInput(btnB, true, true);
9312 }
9313 71669 bool DrunkrEx1btn()
9314 {
9315 71669 return getInput(btnEx1, true, true);
9316 }
9317 71662 bool DrunkrEx2btn()
9318 {
9319 71662 return getInput(btnEx2, true, true);
9320 }
9321 bool DrunkrEx3btn()
9322 {
9323 return getInput(btnEx3, true, true);
9324 }
9325 bool DrunkrEx4btn()
9326 {
9327 return getInput(btnEx4, true, true);
9328 }
9329 bool DrunkrSbtn()
9330 {
9331 return getInput(btnS, true, true);
9332 }
9333 bool DrunkrMbtn()
9334 {
9335 return getInput(btnM, true, true);
9336 }
9337 6688656 bool DrunkrLbtn()
9338 {
9339 6688656 return getInput(btnL, true, true);
9340 }
9341 6685181 bool DrunkrRbtn()
9342 {
9343 6685181 return getInput(btnR, true, true);
9344 }
9345 bool DrunkrPbtn()
9346 {
9347 return getInput(btnP, true, true);
9348 }
9349
9350 9337 void eat_buttons()
9351 {
9352 9337 getInput(btnA, true, false, true);
9353 9337 getInput(btnB, true, false, true);
9354 9337 getInput(btnS, true, false, true);
9355 9337 getInput(btnM, true, false, true);
9356 9337 getInput(btnL, true, false, true);
9357 9337 getInput(btnR, true, false, true);
9358 9337 getInput(btnP, true, false, true);
9359 9337 getInput(btnEx1, true, false, true);
9360 9337 getInput(btnEx2, true, false, true);
9361 9337 getInput(btnEx3, true, false, true);
9362 9337 getInput(btnEx4, true, false, true);
9363 9337 }
9364
9365 // Is true for the _first frame_ of a key press.
9366 // But! it is possible that a script manually sets the value of KeyPress,
9367 // in which case it will be restored to the "true" value based on `key_current_frame`
9368 // and `key_previous_frame` on the next frame.
9369 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9370 {
9371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9373 {
9374 case KEY_F7:
9375 case KEY_F8:
9376 case KEY_F9:
9377 return KeyPress[k];
9378
9379 default:
9380
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 return KeyPress[k] && !disabledKeys[k];
9381 }
9382 14 }
9383
9384 // Is true for _every frame_ a key is held down.
9385 // But! it is possible that a script manually sets the value of KeyInput,
9386 // in which case it will be restored to the "true" value based on `key_current_frame`
9387 // on the next frame.
9388 bool zc_getkey(int32_t k, bool ignoreDisable)
9389 {
9390 if(ignoreDisable) return KeyInput[k];
9391 switch(k)
9392 {
9393 case KEY_F7:
9394 case KEY_F8:
9395 case KEY_F9:
9396 return KeyInput[k];
9397
9398 default:
9399 return KeyInput[k] && !disabledKeys[k];
9400 }
9401 }
9402
9403 // Reads (and then clears) the current frame key state directly.
9404 // Scripts can also modify `key_current_frame`.
9405 303 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9406 {
9407
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 301 times.
303 if(zc_getrawkey(k, ignoreDisable))
9408 {
9409 2 _key[k]=key[k]=key_current_frame[k]=0;
9410 2 return true;
9411 }
9412 301 _key[k]=key[k]=key_current_frame[k]=0;
9413 301 return false;
9414 303 }
9415
9416 // Reads the current frame key state directly.
9417 // Scripts can also modify `key_current_frame`.
9418 63240339 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9419 {
9420
2/2
✓ Branch 0 taken 53954908 times.
✓ Branch 1 taken 9285431 times.
63240339 if(ignoreDisable) return key_current_frame[k];
9421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285431 times.
9285431 switch(k)
9422 {
9423 case KEY_F7:
9424 case KEY_F8:
9425 case KEY_F9:
9426 return key_current_frame[k];
9427
9428 default:
9429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285431 times.
9285431 return key_current_frame[k] && !disabledKeys[k];
9430 }
9431 63240339 }
9432
9433 // Only used for a handful of keys, like tilde and Function keys.
9434 // This state is never read within the game.
9435 // It exists so that all keyboard input still functions during replay,
9436 // without inadvertently doing things like toggling throttling if the player
9437 // presses ~
9438 9285403 bool zc_get_system_key(int32_t k)
9439 {
9440 9285403 return key_system[k];
9441 }
9442
9443 // True for the _first_ frame of a key press.
9444 83568627 bool zc_read_system_key(int32_t k)
9445 {
9446 83568627 return key_system_press[k];
9447 }
9448
9449 1179246181 bool is_system_key(int32_t k)
9450 {
9451
2/2
✓ Branch 0 taken 1095677554 times.
✓ Branch 1 taken 83568627 times.
1179246181 switch (k)
9452 {
9453 case KEY_BACKQUOTE:
9454 case KEY_CLOSEBRACE:
9455 case KEY_END:
9456 case KEY_HOME:
9457 case KEY_OPENBRACE:
9458 case KEY_PGDN:
9459 case KEY_PGUP:
9460 case KEY_TAB:
9461 case KEY_TILDE:
9462 83568627 return true;
9463 }
9464 1095677554 return is_Fkey(k);
9465 1179246181 }
9466
9467 9285403 void update_system_keys()
9468 {
9469
2/2
✓ Branch 0 taken 1179246181 times.
✓ Branch 1 taken 9285403 times.
1188531584 for (int32_t q = 0; q < 127; ++q)
9470 {
9471
2/2
✓ Branch 0 taken 194993463 times.
✓ Branch 1 taken 984252718 times.
1179246181 if (!is_system_key(q))
9472 984252718 continue;
9473
9474 194993463 key_system[q] = key[q];
9475
1/2
✓ Branch 0 taken 194993463 times.
✗ Branch 1 not taken.
194993463 key_system_press[q] = key_system[q] && !key_system_previous[q];
9476 194993463 key_system_previous[q] = key_system[q];
9477 194993463 }
9478 9285403 }
9479
9480 10388714 void update_keys()
9481 {
9482
2/2
✓ Branch 0 taken 1319366678 times.
✓ Branch 1 taken 10388714 times.
1329755392 for (int32_t q = 0; q < 127; ++q)
9483 {
9484 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9485
1/2
✓ Branch 0 taken 1319366678 times.
✗ Branch 1 not taken.
1319366678 if (!replay_is_replaying())
9486 key_current_frame[q] = key[q];
9487
9488
2/2
✓ Branch 0 taken 1309581109 times.
✓ Branch 1 taken 9785569 times.
1319366678 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9489 1319366678 KeyInput[q] = key_current_frame[q];
9490 1319366678 key_previous_frame[q] = key_current_frame[q];
9491 1319366678 }
9492 10388714 }
9493
9494 bool zc_disablekey(int32_t k, bool val)
9495 {
9496 switch(k)
9497 {
9498 case KEY_F7:
9499 case KEY_F8:
9500 case KEY_F9:
9501 return false;
9502
9503 default:
9504 disabledKeys[k] = val;
9505 return true;
9506 }
9507 }
9508
9509 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9510 {
9511 timer=timer;
9512 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9513 }
9514